Open
Description
Hi
ReScript version: v11.x.x
When using plain variants with an @as
, coercing to string produces the expected result. E.g
type plain =
| Foo
| @as("js") ReScript
let plainToJs = (x: plain) => (x :> string)
let plainOk = plainToJs(ReScript) // "js"
When using polymorphic variants with an @as
, coercing to string produces an unexpected result
type poly = [#foo | @as("js") #rescript]
let polyToJs1 = (x: poly) => (x :> string)
let poly1NotOk = polyToJs1(#rescript) // "rescript"
I'm not sure whether this is expected or if I'm supposed to write
let polyToJs2 = (x: poly) =>
switch x {
| #rescript => "js"
| _ => (x :> string)
}
Playground here