-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Excess property checking does not work correctly with unions with an optional discriminant #38024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is the intended behavior. The provided value is a valid |
@RyanCavanaugh without |
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
@RyanCavanaugh To me, this feels like introducing unnecessary limitations on |
This definitely doesn't seem to be working as intended (or at least, resulting in a functional construct), as attempting to access any property of See modified playground for an example Trying to access either property reveals that neither property works. The type essentially has become an empty object, despite the compiler allowing properties to be set on it. |
TypeScript Version: 3.8.3
Search Terms: excess property checking, unions with optional discriminant
Code
Expected behavior:
For unions to be exclusive,
C
should identify as eitherTYPE_A
orTYPE_B
, or none of them. I.e. the above code snippet should not compile.Actual behavior:
It seems to identify as subpart
TYPE_A
, subpartTYPE_B
.Playground Link:
https://www.typescriptlang.org/play/#code/ATAuE8AcFNgFQJoAUCiB9AgsAvMA3gFAggYBcwAzqAE4CWAdgOYA0RxGaA8knAJKcA5DABkA-OSp0mrEAF8A3AQIQY8ZOgBCOfGxAaJNBi13ANXHvyHCDU4wqUBjAPb0qwAMLlEqTMAA+aj5auITEwGTAAOQAZk5OkTLEZtx8giKkkQBGAIbUkQSyQA
Related Issues:
#20863
The text was updated successfully, but these errors were encountered: