Skip to content

Normalize target type after null-stripping unions in relationship checks #43202

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

Merged
merged 2 commits into from
Mar 19, 2021

Conversation

ahejlsberg
Copy link
Member

Fixes #43152.

@DanielRosenwasser
Copy link
Member

Why does it work with the other unions? Do we normalize in other parts of isRelatedTo?

@ahejlsberg
Copy link
Member Author

@DanielRosenwasser We first normalize both the source and target types. We then do some tests for common patterns, one of which is for an object type on the source side and a union that includes undefined and/or null on the target side. When we see this pattern, we immediately remove undefined and null from the target. But we then need to re-normalize the remaining target, and that's what this PR adds.

@ahejlsberg ahejlsberg merged commit fbc9c94 into master Mar 19, 2021
@ahejlsberg ahejlsberg deleted the fix43152 branch March 19, 2021 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4.2 regression: TS2345: argument is not assignable to a parameter of a generic type
3 participants