Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 1965

Cast unbox to primitive

$
0
0

Hello,

I have variant type of strings:

@unboxed
type firestoreErrorCode =
  | @as("cancelled") Cancelled
  | @as("unknown") Unknown
  | @as("invalid-argument") InvalidArgument
  | @as("deadline-exceeded") DeadlineExceeded
  | @as("not-found") NotFound
  | @as("already-exists") AlreadyExists
  | @as("permission-denied") PermissionDenied
  | @as("resource-exhausted") ResourceExhausted
  | @as("failed-precondition") FailedPrecondition
  | @as("aborted") Aborted
  | @as("out-of-range") OutOfRange
  | @as("unimplemented") Unimplemented
  | @as("internal") Internal
  | @as("unavailable") Unavailable
  | @as("data-loss") DataLoss
  | @as("unauthenticated") Unauthenticated

let code = Cancelled
// Does not work
let e = React.string(code)

But now I want to cast this back to a raw string to pass to React.string, is there a dedicate helper for this or do I need to create a function myself?


Viewing all articles
Browse latest Browse all 1965

Trending Articles