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
...which makes sense because this is working as intended. Discriminated unions in TS require the discriminant property to be of a literal/unit/singleton type in at least one of the members of the union. Neither string nor number are literal types, so the type property of Data2 is not a discriminant property.
Bug Report
π Search Terms
Narrowing Union literal
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
When discriminator property is not literal type in discriminated unions, type of
Data2
is not narrowed as expected.π Expected behavior
Type of
Data2
can be narrowed just likeData1
The text was updated successfully, but these errors were encountered: