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

Preserve generics in contextual types for rest arguments #44122

Merged
merged 5 commits into from
May 19, 2021
Merged

Conversation

ahejlsberg
Copy link
Member

This PR ensures that generics are preserved in contextual types for arguments to rest parameters with union types. The PR additionally cleans up the getIndexedAccessType and getIndexedAccessTypeOrUndefined functions which had grown quite unwieldy as a result of introducing the --noUncheckedIndexedAccess compiler switch. Instead of multiple discreet boolean arguments, all modifiers are now passed through the AccessFlags enum.

Fixes #44093.

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels May 17, 2021
@DanielRosenwasser
Copy link
Member

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 17, 2021

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 17, 2021

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 17, 2021

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 17, 2021

Heya @DanielRosenwasser, I've started to run the perf test suite on this PR at d54f580. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - master..44122

Metric master 44122 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 345,047k (± 0.01%) 345,140k (± 0.02%) +93k (+ 0.03%) 345,016k 345,338k
Parse Time 1.90s (± 0.72%) 1.92s (± 0.69%) +0.01s (+ 0.68%) 1.90s 1.96s
Bind Time 0.84s (± 0.80%) 0.84s (± 0.66%) +0.00s (+ 0.12%) 0.83s 0.85s
Check Time 5.25s (± 0.68%) 5.26s (± 0.51%) +0.01s (+ 0.10%) 5.20s 5.31s
Emit Time 5.57s (± 0.59%) 5.56s (± 0.44%) -0.01s (- 0.27%) 5.49s 5.61s
Total Time 13.57s (± 0.41%) 13.57s (± 0.25%) 0.00s ( 0.00%) 13.45s 13.62s
Compiler-Unions - node (v10.16.3, x64)
Memory used 200,388k (± 0.03%) 200,405k (± 0.05%) +17k (+ 0.01%) 200,206k 200,670k
Parse Time 0.78s (± 0.46%) 0.78s (± 0.87%) 0.00s ( 0.00%) 0.77s 0.80s
Bind Time 0.53s (± 1.29%) 0.53s (± 1.09%) +0.00s (+ 0.76%) 0.52s 0.54s
Check Time 7.53s (± 0.48%) 7.51s (± 0.44%) -0.02s (- 0.23%) 7.45s 7.59s
Emit Time 2.45s (± 0.93%) 2.47s (± 2.31%) +0.01s (+ 0.57%) 2.41s 2.68s
Total Time 11.29s (± 0.38%) 11.29s (± 0.58%) +0.00s (+ 0.03%) 11.18s 11.50s
Monaco - node (v10.16.3, x64)
Memory used 341,667k (± 0.02%) 341,721k (± 0.03%) +55k (+ 0.02%) 341,534k 342,012k
Parse Time 1.55s (± 0.60%) 1.55s (± 0.72%) -0.01s (- 0.45%) 1.51s 1.57s
Bind Time 0.74s (± 0.75%) 0.74s (± 0.78%) +0.00s (+ 0.13%) 0.73s 0.76s
Check Time 5.39s (± 0.70%) 5.39s (± 0.41%) -0.00s (- 0.02%) 5.35s 5.46s
Emit Time 2.97s (± 0.70%) 2.95s (± 0.62%) -0.01s (- 0.40%) 2.92s 3.00s
Total Time 10.65s (± 0.53%) 10.63s (± 0.39%) -0.02s (- 0.21%) 10.56s 10.73s
TFS - node (v10.16.3, x64)
Memory used 304,248k (± 0.02%) 304,187k (± 0.02%) -61k (- 0.02%) 304,031k 304,300k
Parse Time 1.21s (± 0.46%) 1.21s (± 0.54%) -0.00s (- 0.00%) 1.20s 1.23s
Bind Time 0.71s (± 0.67%) 0.70s (± 0.68%) -0.00s (- 0.57%) 0.69s 0.71s
Check Time 4.84s (± 0.47%) 4.86s (± 0.61%) +0.02s (+ 0.31%) 4.79s 4.93s
Emit Time 3.14s (± 1.19%) 3.12s (± 1.76%) -0.02s (- 0.67%) 2.95s 3.23s
Total Time 9.90s (± 0.45%) 9.89s (± 0.72%) -0.01s (- 0.11%) 9.72s 10.08s
material-ui - node (v10.16.3, x64)
Memory used 474,028k (± 0.01%) 474,151k (± 0.01%) +123k (+ 0.03%) 474,085k 474,258k
Parse Time 1.94s (± 0.89%) 1.93s (± 1.12%) -0.01s (- 0.36%) 1.90s 1.98s
Bind Time 0.66s (± 0.76%) 0.65s (± 1.04%) -0.00s (- 0.15%) 0.64s 0.67s
Check Time 14.24s (± 0.35%) 14.15s (± 0.38%) -0.09s (- 0.61%) 14.06s 14.32s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 16.84s (± 0.32%) 16.74s (± 0.36%) -0.09s (- 0.55%) 16.63s 16.95s
Angular - node (v12.1.0, x64)
Memory used 322,607k (± 0.02%) 322,708k (± 0.02%) +101k (+ 0.03%) 322,541k 322,878k
Parse Time 1.90s (± 0.63%) 1.91s (± 0.55%) +0.00s (+ 0.21%) 1.89s 1.93s
Bind Time 0.82s (± 0.71%) 0.82s (± 0.81%) +0.00s (+ 0.37%) 0.81s 0.84s
Check Time 5.15s (± 0.32%) 5.16s (± 0.29%) +0.01s (+ 0.10%) 5.12s 5.19s
Emit Time 5.78s (± 0.80%) 5.82s (± 1.57%) +0.03s (+ 0.55%) 5.71s 6.17s
Total Time 13.66s (± 0.48%) 13.70s (± 0.70%) +0.04s (+ 0.31%) 13.61s 14.08s
Compiler-Unions - node (v12.1.0, x64)
Memory used 187,549k (± 0.16%) 187,697k (± 0.13%) +149k (+ 0.08%) 187,133k 188,064k
Parse Time 0.77s (± 0.78%) 0.77s (± 0.91%) +0.01s (+ 0.65%) 0.76s 0.79s
Bind Time 0.53s (± 1.32%) 0.53s (± 0.89%) -0.00s (- 0.19%) 0.52s 0.54s
Check Time 7.04s (± 0.64%) 7.01s (± 0.40%) -0.02s (- 0.33%) 6.94s 7.08s
Emit Time 2.43s (± 1.68%) 2.39s (± 1.00%) -0.04s (- 1.72%) 2.35s 2.46s
Total Time 10.77s (± 0.65%) 10.71s (± 0.30%) -0.06s (- 0.54%) 10.62s 10.75s
Monaco - node (v12.1.0, x64)
Memory used 323,988k (± 0.05%) 324,059k (± 0.03%) +71k (+ 0.02%) 323,854k 324,230k
Parse Time 1.54s (± 0.66%) 1.53s (± 0.46%) -0.01s (- 0.33%) 1.51s 1.54s
Bind Time 0.72s (± 0.83%) 0.72s (± 0.72%) +0.00s (+ 0.70%) 0.71s 0.73s
Check Time 5.21s (± 0.36%) 5.21s (± 0.45%) -0.01s (- 0.10%) 5.14s 5.26s
Emit Time 3.04s (± 1.05%) 3.00s (± 0.75%) -0.03s (- 1.09%) 2.95s 3.05s
Total Time 10.50s (± 0.38%) 10.46s (± 0.36%) -0.04s (- 0.34%) 10.36s 10.52s
TFS - node (v12.1.0, x64)
Memory used 288,704k (± 0.02%) 288,688k (± 0.02%) -16k (- 0.01%) 288,599k 288,808k
Parse Time 1.21s (± 0.62%) 1.21s (± 0.58%) +0.00s (+ 0.33%) 1.20s 1.23s
Bind Time 0.70s (± 0.99%) 0.69s (± 0.49%) -0.00s (- 0.29%) 0.69s 0.70s
Check Time 4.76s (± 0.29%) 4.74s (± 0.32%) -0.01s (- 0.23%) 4.71s 4.78s
Emit Time 3.13s (± 0.77%) 3.13s (± 0.96%) -0.00s (- 0.03%) 3.06s 3.20s
Total Time 9.78s (± 0.32%) 9.77s (± 0.31%) -0.01s (- 0.12%) 9.71s 9.87s
material-ui - node (v12.1.0, x64)
Memory used 451,959k (± 0.01%) 451,615k (± 0.09%) -343k (- 0.08%) 450,674k 452,156k
Parse Time 1.95s (± 0.56%) 1.94s (± 0.56%) -0.01s (- 0.62%) 1.92s 1.97s
Bind Time 0.64s (± 0.87%) 0.64s (± 0.57%) -0.00s (- 0.31%) 0.63s 0.64s
Check Time 12.81s (± 0.48%) 12.82s (± 0.68%) +0.01s (+ 0.11%) 12.69s 13.04s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.40s (± 0.40%) 15.40s (± 0.57%) -0.00s (- 0.01%) 15.26s 15.62s
Angular - node (v14.15.1, x64)
Memory used 321,295k (± 0.00%) 321,397k (± 0.01%) +102k (+ 0.03%) 321,343k 321,429k
Parse Time 1.91s (± 0.70%) 1.90s (± 0.63%) -0.01s (- 0.42%) 1.89s 1.94s
Bind Time 0.87s (± 0.34%) 0.87s (± 0.77%) -0.00s (- 0.12%) 0.86s 0.89s
Check Time 5.17s (± 0.41%) 5.17s (± 0.43%) -0.00s (- 0.08%) 5.12s 5.23s
Emit Time 5.81s (± 0.36%) 5.87s (± 0.70%) +0.05s (+ 0.91%) 5.81s 5.98s
Total Time 13.76s (± 0.32%) 13.80s (± 0.40%) +0.04s (+ 0.31%) 13.71s 13.90s
Compiler-Unions - node (v14.15.1, x64)
Memory used 188,755k (± 0.58%) 188,462k (± 0.61%) -292k (- 0.15%) 186,516k 189,754k
Parse Time 0.80s (± 0.50%) 0.80s (± 0.45%) +0.01s (+ 0.63%) 0.80s 0.81s
Bind Time 0.55s (± 0.62%) 0.55s (± 0.62%) 0.00s ( 0.00%) 0.55s 0.56s
Check Time 7.14s (± 0.47%) 7.12s (± 0.32%) -0.03s (- 0.38%) 7.06s 7.18s
Emit Time 2.44s (± 0.91%) 2.42s (± 0.96%) -0.02s (- 0.82%) 2.37s 2.49s
Total Time 10.93s (± 0.38%) 10.89s (± 0.34%) -0.04s (- 0.37%) 10.82s 10.97s
Monaco - node (v14.15.1, x64)
Memory used 323,157k (± 0.00%) 323,155k (± 0.01%) -2k (- 0.00%) 323,105k 323,185k
Parse Time 1.56s (± 0.69%) 1.57s (± 0.52%) +0.01s (+ 0.58%) 1.55s 1.59s
Bind Time 0.74s (± 0.66%) 0.74s (± 0.46%) -0.00s (- 0.13%) 0.74s 0.75s
Check Time 5.20s (± 0.32%) 5.21s (± 0.58%) +0.00s (+ 0.10%) 5.16s 5.28s
Emit Time 3.07s (± 0.71%) 3.06s (± 0.53%) -0.01s (- 0.46%) 3.03s 3.10s
Total Time 10.58s (± 0.35%) 10.58s (± 0.32%) 0.00s ( 0.00%) 10.51s 10.68s
TFS - node (v14.15.1, x64)
Memory used 287,671k (± 0.01%) 287,672k (± 0.01%) +1k (+ 0.00%) 287,603k 287,741k
Parse Time 1.28s (± 2.18%) 1.27s (± 1.65%) -0.01s (- 0.93%) 1.24s 1.34s
Bind Time 0.72s (± 1.51%) 0.72s (± 0.95%) -0.01s (- 0.83%) 0.71s 0.74s
Check Time 4.84s (± 1.16%) 4.80s (± 0.43%) -0.04s (- 0.89%) 4.76s 4.86s
Emit Time 3.23s (± 0.96%) 3.20s (± 0.68%) -0.03s (- 0.93%) 3.15s 3.23s
Total Time 10.07s (± 1.12%) 9.98s (± 0.34%) -0.10s (- 0.94%) 9.90s 10.05s
material-ui - node (v14.15.1, x64)
Memory used 450,147k (± 0.01%) 450,216k (± 0.01%) +69k (+ 0.02%) 450,157k 450,279k
Parse Time 1.99s (± 0.65%) 2.00s (± 0.45%) +0.01s (+ 0.40%) 1.98s 2.02s
Bind Time 0.70s (± 1.14%) 0.70s (± 0.95%) -0.00s (- 0.28%) 0.69s 0.72s
Check Time 12.95s (± 0.58%) 12.93s (± 0.33%) -0.02s (- 0.15%) 12.79s 13.00s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.64s (± 0.53%) 15.63s (± 0.24%) -0.02s (- 0.10%) 15.51s 15.69s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-206-generic
Architecturex64
Available Memory16 GB
Available Memory6 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v10.16.3, x64)
  • node (v12.1.0, x64)
  • node (v14.15.1, x64)
Scenarios
  • Angular - node (v10.16.3, x64)
  • Angular - node (v12.1.0, x64)
  • Angular - node (v14.15.1, x64)
  • Compiler-Unions - node (v10.16.3, x64)
  • Compiler-Unions - node (v12.1.0, x64)
  • Compiler-Unions - node (v14.15.1, x64)
  • Monaco - node (v10.16.3, x64)
  • Monaco - node (v12.1.0, x64)
  • Monaco - node (v14.15.1, x64)
  • TFS - node (v10.16.3, x64)
  • TFS - node (v12.1.0, x64)
  • TFS - node (v14.15.1, x64)
  • material-ui - node (v10.16.3, x64)
  • material-ui - node (v12.1.0, x64)
  • material-ui - node (v14.15.1, x64)
Benchmark Name Iterations
Current 44122 10
Baseline master 10

Developer Information:

Download Benchmark

@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.

# Conflicts:
#	src/compiler/checker.ts
@ahejlsberg ahejlsberg merged commit e67da8a into master May 19, 2021
@ahejlsberg ahejlsberg deleted the fix44093 branch May 19, 2021 20:46
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.

Regression: Rest parameter typed as union of tuple types behaves differently in 4.3
4 participants