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
You can access each part of the union independently.
// No benefit over normal union.if('bar'invalue){// `value ` will be typed as `{ bar: number; }`}// No benefit over normal union.if('baz'invalue){// `value` will be typed as `{ baz: string; qux?: number; }`}// This benefits from the non-discriminated unionif('bar'invalue&&'baz'invalue){// `value` will be typed as `{ bar: number; baz: string; qux?: number; }`// `value` would be `never` with a normal union}
Upvote & Fund
We're using Polar.sh so you can upvote and help fund this issue.
The funding will be given to active contributors.
Thank you in advance for helping prioritize & fund our backlog.
The text was updated successfully, but these errors were encountered:
I'm looking for this type too. I found a solution here and it's working fine but it's a lot of code. It will be great to have NonDiscriminatedUnion<T> or AllFields<T>
For a union of only 2 elements, this would just be:
However, the type would be more complex for the case of 3 or more elements.
Example usage
Given these types:
If you have a value typed as
NonDiscriminatedFoo
You can access each part of the union independently.
Upvote & Fund
The text was updated successfully, but these errors were encountered: