Skip to content
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

Merged

Conversation

weswigham
Copy link
Member

@weswigham weswigham commented Apr 18, 2019

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" by compareSignaturesIdentical, since it erased the type parameters to any (causing their different return types to both look like any). 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).

@sandersn
Copy link
Member

sandersn commented Mar 3, 2020

The linked issue is now fixed, so I'm closing this. @weswigham feel free to re-open if that's not correct.

@sandersn sandersn closed this Mar 3, 2020
@weswigham
Copy link
Member Author

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.

@weswigham weswigham reopened this Mar 4, 2020
@weswigham weswigham changed the title Have signature identity checks look at the base constraint of type parameters Allow identical type parameter lists to merge in union signatures Mar 4, 2020
@weswigham
Copy link
Member Author

@sandersn I've refreshed this PR, renamed it, and redone the OP with links to relevant issues.

@weswigham
Copy link
Member Author

@typescript-bot run dt
@typescript-bot perf test this
@typescript-bot test this
@typescript-bot user test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 4, 2020

Heya @weswigham, I've started to run the parallelized Definitely Typed test suite on this PR at e14c58e. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 4, 2020

Heya @weswigham, I've started to run the extended test suite on this PR at e14c58e. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 4, 2020

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!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 4, 2020

Heya @weswigham, I've started to run the parallelized community code test suite on this PR at e14c58e. You can monitor the build here.

@nateabele
Copy link

Glad to see movement on this. I keep running into it when I try to do basically any non-trivial data modeling.

@justjake
Copy link

Is this going to make it into TS 4.0?

return createSymbolWithType(left, thisType);
}

function combineUnionParameters(left: Signature, right: Signature) {
function combineUnionParameters(left: Signature, right: Signature, mapper: TypeMapper | undefined) {
Copy link
Member

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?

@andrewbranch
Copy link
Member

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 22, 2020

Heya @andrewbranch, I've started to run the tarball bundle task on this PR at e14c58e. You can monitor the build here.

@weswigham
Copy link
Member Author

@typescript-bot run dt
@typescript-bot user test this
@typescript-bot perf test this
@typescript-bot test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Dec 15, 2020

Heya @weswigham, I've started to run the parallelized community code test suite on this PR at 3037443. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Dec 15, 2020

Heya @weswigham, I've started to run the parallelized Definitely Typed test suite on this PR at 3037443. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Dec 15, 2020

Heya @weswigham, I've started to run the extended test suite on this PR at 3037443. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Dec 15, 2020

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!

@typescript-bot
Copy link
Collaborator

@weswigham
The results of the perf run you requested are in!

Here they are:

Comparison Report - master..31023

Metric master 31023 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 345,031k (± 0.02%) 345,079k (± 0.03%) +49k (+ 0.01%) 344,853k 345,286k
Parse Time 1.99s (± 0.53%) 1.98s (± 0.46%) -0.01s (- 0.55%) 1.96s 2.00s
Bind Time 0.82s (± 0.60%) 0.83s (± 0.70%) +0.00s (+ 0.24%) 0.82s 0.84s
Check Time 4.99s (± 0.75%) 4.98s (± 0.34%) -0.01s (- 0.14%) 4.95s 5.03s
Emit Time 5.34s (± 0.68%) 5.34s (± 0.82%) +0.01s (+ 0.11%) 5.24s 5.43s
Total Time 13.15s (± 0.55%) 13.14s (± 0.44%) -0.01s (- 0.09%) 12.97s 13.24s
Compiler-Unions - node (v10.16.3, x64)
Memory used 205,420k (± 0.06%) 205,417k (± 0.06%) -4k (- 0.00%) 204,990k 205,619k
Parse Time 0.79s (± 0.85%) 0.79s (± 0.87%) -0.00s (- 0.13%) 0.78s 0.81s
Bind Time 0.50s (± 0.80%) 0.50s (± 1.50%) -0.00s (- 0.40%) 0.48s 0.51s
Check Time 12.10s (± 0.51%) 12.10s (± 0.78%) +0.00s (+ 0.04%) 11.92s 12.29s
Emit Time 2.33s (± 1.07%) 2.36s (± 1.46%) +0.03s (+ 1.20%) 2.30s 2.47s
Total Time 15.71s (± 0.36%) 15.74s (± 0.58%) +0.03s (+ 0.19%) 15.55s 15.93s
Monaco - node (v10.16.3, x64)
Memory used 354,920k (± 0.02%) 354,947k (± 0.02%) +27k (+ 0.01%) 354,747k 355,109k
Parse Time 1.60s (± 0.48%) 1.60s (± 0.63%) +0.01s (+ 0.31%) 1.58s 1.63s
Bind Time 0.73s (± 0.68%) 0.73s (± 0.50%) +0.00s (+ 0.00%) 0.72s 0.73s
Check Time 5.13s (± 0.44%) 5.14s (± 0.47%) +0.01s (+ 0.25%) 5.08s 5.18s
Emit Time 2.83s (± 1.10%) 2.82s (± 0.56%) -0.01s (- 0.28%) 2.79s 2.86s
Total Time 10.28s (± 0.37%) 10.29s (± 0.32%) +0.00s (+ 0.04%) 10.22s 10.36s
TFS - node (v10.16.3, x64)
Memory used 307,932k (± 0.01%) 307,898k (± 0.02%) -34k (- 0.01%) 307,750k 308,103k
Parse Time 1.24s (± 0.48%) 1.24s (± 0.59%) +0.00s (+ 0.16%) 1.22s 1.25s
Bind Time 0.68s (± 0.49%) 0.68s (± 0.72%) +0.00s (+ 0.59%) 0.67s 0.69s
Check Time 4.58s (± 0.38%) 4.62s (± 0.53%) +0.04s (+ 0.96%) 4.57s 4.67s
Emit Time 2.94s (± 0.92%) 2.96s (± 0.81%) +0.02s (+ 0.65%) 2.92s 3.03s
Total Time 9.44s (± 0.45%) 9.50s (± 0.50%) +0.07s (+ 0.69%) 9.42s 9.63s
material-ui - node (v10.16.3, x64)
Memory used 489,874k (± 0.01%) 489,919k (± 0.01%) +45k (+ 0.01%) 489,819k 490,040k
Parse Time 2.07s (± 0.58%) 2.07s (± 0.39%) +0.00s (+ 0.15%) 2.05s 2.09s
Bind Time 0.65s (± 0.73%) 0.66s (± 0.72%) +0.01s (+ 1.55%) 0.65s 0.67s
Check Time 13.63s (± 0.51%) 13.76s (± 0.68%) +0.13s (+ 0.92%) 13.54s 13.95s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 16.35s (± 0.46%) 16.48s (± 0.57%) +0.14s (+ 0.84%) 16.27s 16.68s
Angular - node (v12.1.0, x64)
Memory used 322,835k (± 0.02%) 322,868k (± 0.02%) +33k (+ 0.01%) 322,703k 323,007k
Parse Time 1.96s (± 0.46%) 1.96s (± 0.38%) +0.00s (+ 0.05%) 1.94s 1.97s
Bind Time 0.81s (± 0.42%) 0.81s (± 0.64%) -0.00s (- 0.25%) 0.80s 0.83s
Check Time 4.90s (± 0.55%) 4.90s (± 0.36%) +0.01s (+ 0.12%) 4.87s 4.94s
Emit Time 5.49s (± 0.46%) 5.50s (± 0.59%) +0.01s (+ 0.16%) 5.42s 5.59s
Total Time 13.16s (± 0.27%) 13.17s (± 0.30%) +0.02s (+ 0.13%) 13.11s 13.29s
Compiler-Unions - node (v12.1.0, x64)
Memory used 191,685k (± 0.03%) 191,640k (± 0.03%) -46k (- 0.02%) 191,507k 191,726k
Parse Time 0.77s (± 0.98%) 0.78s (± 0.61%) +0.00s (+ 0.39%) 0.77s 0.79s
Bind Time 0.49s (± 0.60%) 0.50s (± 1.11%) +0.01s (+ 2.03%) 0.49s 0.51s
Check Time 10.81s (± 0.79%) 10.93s (± 1.19%) +0.12s (+ 1.16%) 10.66s 11.29s
Emit Time 2.35s (± 0.91%) 2.38s (± 1.01%) +0.03s (+ 1.06%) 2.31s 2.43s
Total Time 14.43s (± 0.57%) 14.59s (± 0.90%) +0.16s (+ 1.09%) 14.33s 14.93s
Monaco - node (v12.1.0, x64)
Memory used 336,972k (± 0.01%) 337,043k (± 0.01%) +71k (+ 0.02%) 336,943k 337,162k
Parse Time 1.58s (± 0.57%) 1.59s (± 1.19%) +0.01s (+ 0.82%) 1.55s 1.64s
Bind Time 0.71s (± 1.05%) 0.71s (± 0.73%) -0.00s (- 0.28%) 0.70s 0.72s
Check Time 4.93s (± 0.35%) 4.92s (± 0.49%) -0.00s (- 0.10%) 4.88s 4.99s
Emit Time 2.85s (± 0.54%) 2.86s (± 0.60%) +0.01s (+ 0.46%) 2.84s 2.91s
Total Time 10.07s (± 0.19%) 10.08s (± 0.58%) +0.01s (+ 0.14%) 9.97s 10.27s
TFS - node (v12.1.0, x64)
Memory used 292,204k (± 0.02%) 292,179k (± 0.01%) -25k (- 0.01%) 292,118k 292,257k
Parse Time 1.25s (± 0.62%) 1.25s (± 0.66%) +0.00s (+ 0.32%) 1.24s 1.27s
Bind Time 0.65s (± 0.56%) 0.65s (± 1.02%) -0.00s (- 0.61%) 0.64s 0.66s
Check Time 4.52s (± 0.63%) 4.53s (± 0.65%) +0.01s (+ 0.11%) 4.48s 4.62s
Emit Time 2.96s (± 0.79%) 2.95s (± 0.75%) -0.01s (- 0.30%) 2.90s 3.00s
Total Time 9.39s (± 0.50%) 9.39s (± 0.43%) -0.00s (- 0.03%) 9.29s 9.48s
material-ui - node (v12.1.0, x64)
Memory used 467,870k (± 0.01%) 467,677k (± 0.08%) -194k (- 0.04%) 466,634k 468,045k
Parse Time 2.07s (± 0.47%) 2.08s (± 0.59%) +0.01s (+ 0.43%) 2.05s 2.11s
Bind Time 0.64s (± 1.01%) 0.64s (± 1.18%) +0.00s (+ 0.31%) 0.63s 0.67s
Check Time 12.05s (± 0.57%) 12.25s (± 1.06%) +0.20s (+ 1.68%) 12.08s 12.57s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 14.76s (± 0.46%) 14.97s (± 0.83%) +0.22s (+ 1.47%) 14.80s 15.27s
Angular - node (v8.9.0, x64)
Memory used 347,697k (± 0.03%) 347,714k (± 0.02%) +17k (+ 0.00%) 347,543k 347,827k
Parse Time 2.52s (± 0.55%) 2.51s (± 0.29%) -0.02s (- 0.63%) 2.50s 2.53s
Bind Time 0.87s (± 0.69%) 0.87s (± 0.95%) 0.00s ( 0.00%) 0.85s 0.88s
Check Time 5.63s (± 0.76%) 5.65s (± 0.83%) +0.02s (+ 0.36%) 5.55s 5.76s
Emit Time 6.32s (± 1.34%) 6.31s (± 0.59%) -0.00s (- 0.06%) 6.19s 6.37s
Total Time 15.34s (± 0.79%) 15.34s (± 0.48%) +0.00s (+ 0.03%) 15.22s 15.52s
Compiler-Unions - node (v8.9.0, x64)
Memory used 213,198k (± 0.02%) 213,193k (± 0.02%) -5k (- 0.00%) 213,106k 213,287k
Parse Time 0.95s (± 0.59%) 0.94s (± 0.63%) -0.00s (- 0.42%) 0.93s 0.96s
Bind Time 0.58s (± 0.96%) 0.58s (± 0.86%) -0.00s (- 0.35%) 0.57s 0.59s
Check Time 14.85s (± 0.88%) 14.92s (± 0.57%) +0.07s (+ 0.45%) 14.81s 15.23s
Emit Time 2.76s (± 1.89%) 2.74s (± 2.49%) -0.02s (- 0.73%) 2.61s 2.87s
Total Time 19.13s (± 0.80%) 19.18s (± 0.70%) +0.05s (+ 0.25%) 18.95s 19.57s
Monaco - node (v8.9.0, x64)
Memory used 358,784k (± 0.01%) 358,832k (± 0.01%) +49k (+ 0.01%) 358,755k 358,916k
Parse Time 1.92s (± 0.46%) 1.93s (± 0.41%) +0.01s (+ 0.26%) 1.91s 1.95s
Bind Time 0.91s (± 0.74%) 0.91s (± 0.68%) +0.00s (+ 0.44%) 0.90s 0.93s
Check Time 5.70s (± 0.46%) 5.67s (± 0.70%) -0.03s (- 0.56%) 5.60s 5.80s
Emit Time 3.41s (± 0.73%) 3.40s (± 0.42%) -0.01s (- 0.23%) 3.36s 3.43s
Total Time 11.94s (± 0.32%) 11.91s (± 0.45%) -0.03s (- 0.28%) 11.80s 12.09s
TFS - node (v8.9.0, x64)
Memory used 310,509k (± 0.02%) 310,574k (± 0.01%) +65k (+ 0.02%) 310,482k 310,657k
Parse Time 1.57s (± 0.54%) 1.57s (± 0.51%) +0.00s (+ 0.06%) 1.56s 1.59s
Bind Time 0.68s (± 0.54%) 0.69s (± 0.53%) +0.00s (+ 0.15%) 0.68s 0.69s
Check Time 5.33s (± 0.52%) 5.34s (± 0.63%) +0.02s (+ 0.28%) 5.26s 5.40s
Emit Time 2.99s (± 0.60%) 2.97s (± 0.56%) -0.01s (- 0.40%) 2.94s 3.01s
Total Time 10.57s (± 0.34%) 10.58s (± 0.31%) +0.01s (+ 0.10%) 10.52s 10.65s
material-ui - node (v8.9.0, x64)
Memory used 497,029k (± 0.01%) 497,055k (± 0.02%) +26k (+ 0.01%) 496,883k 497,412k
Parse Time 2.49s (± 0.53%) 2.51s (± 0.67%) +0.02s (+ 0.88%) 2.47s 2.55s
Bind Time 0.81s (± 1.87%) 0.82s (± 1.20%) +0.01s (+ 1.23%) 0.81s 0.85s
Check Time 18.25s (± 0.32%) 18.16s (± 1.03%) -0.09s (- 0.50%) 17.72s 18.51s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 21.56s (± 0.33%) 21.49s (± 0.92%) -0.06s (- 0.28%) 21.01s 21.90s
Angular - node (v8.9.0, x86)
Memory used 199,437k (± 0.02%) 199,438k (± 0.02%) +1k (+ 0.00%) 199,332k 199,524k
Parse Time 2.44s (± 1.03%) 2.44s (± 1.23%) -0.00s (- 0.12%) 2.39s 2.52s
Bind Time 1.02s (± 0.56%) 1.02s (± 1.27%) -0.00s (- 0.39%) 0.99s 1.05s
Check Time 5.10s (± 0.72%) 5.08s (± 0.35%) -0.02s (- 0.39%) 5.04s 5.13s
Emit Time 6.12s (± 1.07%) 6.10s (± 0.79%) -0.02s (- 0.29%) 5.96s 6.20s
Total Time 14.68s (± 0.62%) 14.64s (± 0.37%) -0.04s (- 0.29%) 14.50s 14.80s
Compiler-Unions - node (v8.9.0, x86)
Memory used 128,197k (± 0.03%) 128,185k (± 0.03%) -12k (- 0.01%) 128,094k 128,248k
Parse Time 0.96s (± 0.79%) 0.97s (± 0.77%) +0.01s (+ 0.62%) 0.95s 0.98s
Bind Time 0.49s (± 0.91%) 0.49s (± 0.68%) +0.00s (+ 0.41%) 0.48s 0.50s
Check Time 13.99s (± 0.28%) 14.02s (± 0.55%) +0.04s (+ 0.26%) 13.90s 14.22s
Emit Time 2.62s (± 1.28%) 2.62s (± 0.75%) 0.00s ( 0.00%) 2.57s 2.65s
Total Time 18.06s (± 0.30%) 18.10s (± 0.41%) +0.04s (+ 0.22%) 17.99s 18.28s
Monaco - node (v8.9.0, x86)
Memory used 203,282k (± 0.02%) 203,287k (± 0.02%) +6k (+ 0.00%) 203,167k 203,354k
Parse Time 1.97s (± 0.50%) 1.99s (± 1.32%) +0.02s (+ 0.76%) 1.95s 2.06s
Bind Time 0.72s (± 1.06%) 0.72s (± 0.92%) +0.00s (+ 0.56%) 0.71s 0.74s
Check Time 5.76s (± 1.54%) 5.74s (± 1.40%) -0.02s (- 0.36%) 5.48s 5.86s
Emit Time 2.82s (± 3.58%) 2.86s (± 2.96%) +0.04s (+ 1.28%) 2.72s 3.11s
Total Time 11.27s (± 0.25%) 11.31s (± 0.45%) +0.04s (+ 0.32%) 11.17s 11.43s
TFS - node (v8.9.0, x86)
Memory used 177,650k (± 0.02%) 177,688k (± 0.02%) +38k (+ 0.02%) 177,625k 177,743k
Parse Time 1.61s (± 1.04%) 1.60s (± 0.88%) -0.01s (- 0.37%) 1.58s 1.63s
Bind Time 0.65s (± 0.76%) 0.65s (± 0.34%) +0.00s (+ 0.77%) 0.65s 0.66s
Check Time 4.91s (± 0.77%) 4.88s (± 0.44%) -0.03s (- 0.55%) 4.83s 4.92s
Emit Time 2.85s (± 0.66%) 2.84s (± 0.53%) -0.01s (- 0.28%) 2.79s 2.87s
Total Time 10.01s (± 0.57%) 9.97s (± 0.39%) -0.04s (- 0.35%) 9.90s 10.05s
material-ui - node (v8.9.0, x86)
Memory used 279,908k (± 0.02%) 279,880k (± 0.01%) -28k (- 0.01%) 279,769k 279,974k
Parse Time 2.54s (± 0.47%) 2.54s (± 0.46%) +0.00s (+ 0.04%) 2.52s 2.57s
Bind Time 0.70s (± 1.27%) 0.72s (± 5.90%) +0.01s (+ 1.84%) 0.68s 0.85s
Check Time 16.64s (± 0.50%) 16.71s (± 0.87%) +0.07s (+ 0.44%) 16.41s 17.05s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 19.89s (± 0.42%) 19.98s (± 0.75%) +0.09s (+ 0.46%) 19.77s 20.41s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-197-generic
Architecturex64
Available Memory16 GB
Available Memory10 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v10.16.3, x64)
  • node (v12.1.0, x64)
  • node (v8.9.0, x64)
  • node (v8.9.0, x86)
Scenarios
  • Angular - node (v10.16.3, x64)
  • Angular - node (v12.1.0, x64)
  • Angular - node (v8.9.0, x64)
  • Angular - node (v8.9.0, x86)
  • Compiler-Unions - node (v10.16.3, x64)
  • Compiler-Unions - node (v12.1.0, x64)
  • Compiler-Unions - node (v8.9.0, x64)
  • Compiler-Unions - node (v8.9.0, x86)
  • Monaco - node (v10.16.3, x64)
  • Monaco - node (v12.1.0, x64)
  • Monaco - node (v8.9.0, x64)
  • Monaco - node (v8.9.0, x86)
  • TFS - node (v10.16.3, x64)
  • TFS - node (v12.1.0, x64)
  • TFS - node (v8.9.0, x64)
  • TFS - node (v8.9.0, x86)
  • material-ui - node (v10.16.3, x64)
  • material-ui - node (v12.1.0, x64)
  • material-ui - node (v8.9.0, x64)
  • material-ui - node (v8.9.0, x86)
Benchmark Name Iterations
Current 31023 10
Baseline master 10

@typescript-bot
Copy link
Collaborator

The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master.

@weswigham
Copy link
Member Author

All baselines still look good, excellent.

@weswigham weswigham merged commit b217f22 into microsoft:master Dec 16, 2020
@andrewbranch
Copy link
Member

Happy to see this merged! 🥳

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
Archived in project
7 participants