Open samhh opened 3 years ago
A new issue has arisen with this as of #45. Where the following was (maybe?) working before, the type system is now unable to determine if A
constitutes the value of a nullary constructor (comparison against null
here):
type X<A> = Sum.Member<'X', A>
const getX = <A>() => Sum.create<X<A>>()
const f = <A>() => {
const X = getX<A>()
X.mk.X // Sum.Constructor<X<A>, "X", A>
}
This extends to subtyping constraints. Changing A
on f
to for example A extends string
makes no difference as, as far as the type system is concerned, A
could be string & null
.
Could this be solved by representing nullary values with a symbol and switching out to null
when (de)serialising? Depends how the typechecker treats unique symbol
s.
A tracking issue for if this ever becomes viable. In the meantime we should document the challenges faced.