Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Require at least a single match when defining discriminable properties #53654
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
Require at least a single match when defining discriminable properties #53654
Changes from all commits
2f75e38
424bda8
86295fb
b267256
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To explain this change: This line says that "discriminated types stop at 'true'", but the code is overwriting a potentially true
discriminable[i]
tofalse
if one of the union variants has a property with a type that's unrelated to the target type (which is what's happening when the property's value is an incomplete string literal).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of these errors not being included anymore and I'll try to keep them, but IMO the diagnostic changes in the other files do make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DanielRosenwasser @ahejlsberg Wait I think that those errors are a bug (?). The example says that
s
should be assignable tot
(and if you look at it, it is), but it errors because of the number of combinations being too complex. The diagnostics are incorrect, and so I actually prefer them going away.