There are three values in JavaScript:
Result.granted
Result.denied
Result.neverAskAgain
How can they be converted to a variant?
type result =
| Granted
| Denied
| NeverAskAgain;
There are three values in JavaScript:
Result.granted
Result.denied
Result.neverAskAgain
How can they be converted to a variant?
type result =
| Granted
| Denied
| NeverAskAgain;
Edit: a better option is to use https://bucklescript.github.io/docs/en/generate-converters-accessors#usage-5
You can bind to the values, then write a function which converts the values into a variant.
Bind to the values:
type t';
[@bs.module "result"] external granted: t';
[@bs.module "result"] external denied: t';
[@bs.module "result"] external neverAskAgain: t';
Then convert them into the variant:
type t = Granted | Denied | NeverAskAgain;
let fromJS = t' =>
switch (t' === granted, t' === denied, t' === neverAskAgain) {
| (true, _, _) => Granted
| (_, true, _) => Denied
| (_, _, true) => NeverAskAgain
};