-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Fixed type parameter leak in union calls with mixed type parameter presence #57371
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
Fixed type parameter leak in union calls with mixed type parameter presence #57371
Conversation
@@ -13540,6 +13540,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { | |||
result.compositeSignatures = concatenate(left.compositeKind !== TypeFlags.Intersection && left.compositeSignatures || [left], [right]); | |||
if (paramMapper) { |
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.
the gist of the issue was that first 2 calls with type params were unionized here (so paramMapper
was created and attached to became left.mapper
in the next iteration) but then that composite signature was unionized with one without the type params so the left.mapper
wasn't attached to the result
(because paramMapper
was not created this time)
@@ -13540,6 +13540,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { | |||
result.compositeSignatures = concatenate(left.compositeKind !== TypeFlags.Intersection && left.compositeSignatures || [left], [right]); | |||
if (paramMapper) { | |||
result.mapper = left.compositeKind !== TypeFlags.Intersection && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; | |||
} | |||
else if (left.compositeKind !== TypeFlags.Intersection && left.mapper && left.compositeSignatures) { |
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.
This whole function is very similar to combineSignaturesOfIntersectionMembers
so I thought that there might be a similar problem there but so far I couldn't create a test case that would manifest an issue there.
It's also worth noting that both of those functions check left.compositeKind
but it's never the "other one" in the existing test suite (in combineSignaturesOfIntersectionMembers
we never witness left.compositeKind === TypeFlags.Union
and in combineSignaturesOfUnionMembers
we never witness left.compositeKind === TypeFlags.Intersection
). So either some tests are missing or those branches are unused.
8f10bf7
to
a4f0d66
Compare
@typescript-bot run dt |
Heya @weswigham, I've started to run the parallelized Definitely Typed test suite on this PR at a4f0d66. You can monitor the build here. Update: The results are in! |
Heya @weswigham, I've started to run the public perf test suite on this PR at a4f0d66. You can monitor the build here. Update: The results are in! |
Heya @weswigham, I've started to run the diff-based top-repos suite on this PR at a4f0d66. You can monitor the build here. Update: The results are in! |
Heya @weswigham, I've started to run the tarball bundle task on this PR at a4f0d66. You can monitor the build here. |
Hey @weswigham, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build and an npm module you can use via |
@weswigham Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
Hey @weswigham, the results of running the DT tests are ready. |
@weswigham Here are the results of running the top-repos suite comparing Everything looks good! |
fixes #57356