@unwrap poly variant not honored?

Exploring @unwrap for use in foreign interfaces and it seems incomplete in covariant position?

// A js library for a select input that can be either single or multi select.
@unwrap
 type value<'option> = [#Option('option) | #Options(array<'option>)]

let defaultValue: option<Types.value<'optionType>> = defaultValue->Option.map((v): Types.value<'o> => #Option(v))

Js.Console.log2("RSSDV", defaultValue)

Prints

RSSDV {NAME: "Option", VAL: {…}}

I was expecting this value to be unboxed?
The boxed value is getting passed into my select component and breaks rendering, unsurprisingly

Thanks
A

@unwrap only works when it is inline inside an external declaration. 
It doesn’t work in a normal type definition.

eg: Playground

2 Likes

An error here would be good

2 Likes