I'm trying to do something like the following:
let str_result: Js.Nullable.t(string) = Js.Nullable.return("something");
let int_result: Js.Nullable.t(int) = Js.Nullable.fromOption(Some(5));
Js.log([|str_result, int_result|]);
But of course, I get the following complaint:
Error: This expression has type Js.Nullable.t(int) = Js.nullable(int)
but an expression was expected of type
Js.Nullable.t(string) = Js.nullable(string)
Type int is not compatible with type string
So I use string_of_int
:
Js.log([|str_result, string_of_int|]);
But I then run into the problem of:
This has type:
Js.Nullable.t(int) (defined as Js.nullable(int))
But somewhere wanted:
int
Is the proper way to use a switch
or is there another way to do this?