You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Discriminated unions are really unions of objects that have discriminant properties.
We say that a property is considered a discriminant if its type differs in at least two constituents, and one of those constituents is a literal-like type.
For template string types, you need information about the contextual type before you can make any decision about the template literal itself.
So we can't get a narrowed contextual type.
End up not getting a more specific type for other properties, assignment fails.
In general, overlapping discriminant types is a bad idea.
A few options.
Do nothing.
Don't consider properties discriminants if one type subsumes the other.
Doesn't work.
Create a notion of "better" discriminants, discriminate on those first.
Why is it the case that we don't create literal types out of template string expressions wihtout a contextual types?
It was too breaky.
The text was updated successfully, but these errors were encountered:
Order-Dependency with Contextual Typing and Discriminated Unions
#57231
The text was updated successfully, but these errors were encountered: