-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Allow identical type parameter lists to merge in union signatures #31023
Allow identical type parameter lists to merge in union signatures #31023
Conversation
…rameters, allow identical type parameter lists to merge in union signatures
The linked issue is now fixed, so I'm closing this. @weswigham feel free to re-open if that's not correct. |
Mmm this was still open because it also happens to fix another suite of issues to do will calling unions of signatures with type parameters; it does need a bit of a refresh, though. |
@sandersn I've refreshed this PR, renamed it, and redone the OP with links to relevant issues. |
@typescript-bot run dt |
Heya @weswigham, I've started to run the parallelized Definitely Typed test suite on this PR at e14c58e. You can monitor the build here. |
Heya @weswigham, I've started to run the extended test suite on this PR at e14c58e. You can monitor the build here. |
Heya @weswigham, I've started to run the perf test suite on this PR at e14c58e. You can monitor the build here. Update: The results are in! |
Heya @weswigham, I've started to run the parallelized community code test suite on this PR at e14c58e. You can monitor the build here. |
Glad to see movement on this. I keep running into it when I try to do basically any non-trivial data modeling. |
Is this going to make it into TS 4.0? |
src/compiler/checker.ts
Outdated
return createSymbolWithType(left, thisType); | ||
} | ||
|
||
function combineUnionParameters(left: Signature, right: Signature) { | ||
function combineUnionParameters(left: Signature, right: Signature, mapper: TypeMapper | undefined) { |
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.
Interesting, it took me a second to grok what this was for. Would it have worked to just instantiateSignature(right, mapper)
and pass that in instead of instantiating each parameter type on demand?
@typescript-bot pack this |
Heya @andrewbranch, I've started to run the tarball bundle task on this PR at e14c58e. You can monitor the build here. |
@typescript-bot run dt |
Heya @weswigham, I've started to run the parallelized community code test suite on this PR at 3037443. You can monitor the build here. |
Heya @weswigham, I've started to run the parallelized Definitely Typed test suite on this PR at 3037443. You can monitor the build here. |
Heya @weswigham, I've started to run the extended test suite on this PR at 3037443. You can monitor the build here. |
Heya @weswigham, I've started to run the perf test suite on this PR at 3037443. You can monitor the build here. Update: The results are in! |
@weswigham Here they are:Comparison Report - master..31023
System
Hosts
Scenarios
|
The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master. |
All baselines still look good, excellent. |
Happy to see this merged! 🥳 |
Finishes fixing #30717
Fixes #36307
Fixes #36390 mostly (for all but the
reduce
case, since that has overloads)In the first linked issue, the call
tmp.get('t')
was allowed because the two differing signatures were seen as "identical" bycompareSignaturesIdentical
, since it erased the type parameters toany
(causing their different return types to both look likeany
). We have since fixed that, however the call was still flagged as an error, but it'd be nice for it to succeed since, ultimately, only the return types differ. So I now allow unions of signatures to merge when their type parameter lists are identical - when this is the case, all following union signature element parameter/return types are instantiated with a mapping of their type parameters into the type parameters from the first type parameter list found. Type parameter defaults are not considered in this mapping (otherwise.then
on promise really doesn't work).