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
typeT=1|2|3interfaceP{a: T}interfaceAextendsP{a: 1b: undefined}interfaceBextendsP{a: 2b: number}interfaceCextendsP{a: 3}typeQ=A|B|Cconsta: Q={a: 1,b: 1}// Good : TypeScript catch error, b must be undefinedconstc: Q={a: 3,b: 1}// Bad : TypeScript didn't catch any error, TS compiler passed it.
🙁 Actual behavior
variable a is error variable c is not error
🙂 Expected behavior
I expected variable c is error when a is 3 variable b shouldn't exits
The text was updated successfully, but these errors were encountered:
typeT=1|3interfaceP{a: T}interfaceAextendsP{a: 1b: undefined}interfaceCextendsP{a: 3}typeQ=A|Cconsta: Q={a: 3,b: 4}// It catch error but type inference is { a: C, b: A}constb: Q={a: 1,b: undefined}// It is Okay { a: A, b: A }
I think In this case variable a must should pass type check Okay....
This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow or the TypeScript Discord community.
Bug Report
TypeScript can't catch error about Multiple tagged union (more 3 tagged union) with undefined
🔎 Search Terms
Multiple tagged union , tagged union with undefined , undefined union
🕗 Version & Regression Information
TypeScript Version : 4.6
Please keep and fill in the line that best applies:
-->
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
variable a is error
variable c is not error
🙂 Expected behavior
I expected variable c is error when a is 3 variable b shouldn't exits
The text was updated successfully, but these errors were encountered: