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

make Array explicitly extend ReadonlyArray and use this type in the callbacks #46781

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

DetachHead
Copy link
Contributor

Fixes #46394

@typescript-bot
Copy link
Collaborator

It looks like you've sent a pull request to update our 'lib' files. These files aren't meant to be edited by hand, as they consist of last-known good states of the compiler and are generated from 'src'. Unless this is necessary, consider closing the pull request and sending a separate PR to update 'src'.

@typescript-bot typescript-bot added the lib update PR modifies files in the `lib` folder label Nov 11, 2021
@typescript-bot
Copy link
Collaborator

The TypeScript team hasn't accepted the linked issue #46394. If you can get it accepted, this PR will have a better chance of being reviewed.

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Nov 11, 2021
@DetachHead
Copy link
Contributor Author

i don't think the bot noticed but i've removed the changes to the top level lib directory

@andrewbranch andrewbranch added the Experiment A fork with an experimental idea which might not make it into master label Nov 11, 2021
@andrewbranch
Copy link
Member

Quite a lot of failing tests already 😅

@DetachHead
Copy link
Contributor Author

@andrewbranch should be good now

@andrewbranch
Copy link
Member

I get why it’s happening and I guess it technically makes sense, but I feel like the baseline changes look kind of confusing and undesirable.

@andrewbranch
Copy link
Member

Just out of curiosity

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 15, 2021

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 15, 2021

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 15, 2021

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

@andrewbranch
The results of the user tests run you requested are in!

Here they are:

Comparison Report - main..refs/pull/46781/merge

[adonis-framework]

1 of 1 projects failed to build with the old tsc

/mnt/ts_downloads/adonis-framework/tsconfig.json

  • error TS2740: Type '() => {}[]' is missing the following properties from type 'any[]': pop, push, reverse, shift, and 28 more.
    • /mnt/ts_downloads/adonis-framework/node_modules/adonis-framework/src/Event/index.js(128,12)

[bcryptjs]

1 of 1 projects failed to build with the old tsc

/mnt/ts_downloads/bcryptjs/tsconfig.json

  • error TS2740: Type 'Buffer' is missing the following properties from type 'number[]': pop, push, shift, splice, and 5 more.
    • /mnt/ts_downloads/bcryptjs/node_modules/bcryptjs/src/bcrypt.js(25,13)

[lodash]

1 of 1 projects failed to build with the old tsc

/mnt/ts_downloads/lodash/tsconfig.json

  • error TS2740: Type 'SetCache' is missing the following properties from type 'any[]': length, pop, reverse, shift, and 28 more.
    • /mnt/ts_downloads/lodash/node_modules/lodash/_baseDifference.js(43,5)

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - main..46781

Metric main 46781 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 354,588k (± 0.01%) 356,612k (± 0.01%) +2,024k (+ 0.57%) 356,546k 356,697k
Parse Time 1.95s (± 0.51%) 1.94s (± 0.58%) -0.01s (- 0.41%) 1.92s 1.97s
Bind Time 0.85s (± 0.53%) 0.84s (± 0.68%) -0.01s (- 0.94%) 0.83s 0.85s
Check Time 5.48s (± 0.42%) 5.50s (± 0.46%) +0.01s (+ 0.26%) 5.45s 5.55s
Emit Time 5.89s (± 0.77%) 5.91s (± 0.58%) +0.02s (+ 0.42%) 5.84s 5.99s
Total Time 14.16s (± 0.47%) 14.19s (± 0.31%) +0.03s (+ 0.18%) 14.10s 14.30s
Compiler-Unions - node (v10.16.3, x64)
Memory used 204,051k (± 0.03%) 203,087k (± 0.02%) -964k (- 0.47%) 202,976k 203,190k
Parse Time 0.79s (± 0.84%) 0.79s (± 0.78%) -0.00s (- 0.13%) 0.77s 0.80s
Bind Time 0.52s (± 1.07%) 0.52s (± 1.66%) +0.00s (+ 0.77%) 0.50s 0.54s
Check Time 7.82s (± 0.56%) 7.86s (± 0.49%) +0.04s (+ 0.58%) 7.77s 7.94s
Emit Time 2.47s (± 1.34%) 2.47s (± 0.64%) +0.00s (+ 0.04%) 2.43s 2.50s
Total Time 11.59s (± 0.46%) 11.64s (± 0.37%) +0.05s (+ 0.42%) 11.55s 11.74s
Monaco - node (v10.16.3, x64)
Memory used 342,442k (± 0.03%) 342,483k (± 0.01%) +41k (+ 0.01%) 342,387k 342,592k
Parse Time 1.48s (± 0.65%) 1.48s (± 0.51%) +0.00s (+ 0.34%) 1.47s 1.51s
Bind Time 0.75s (± 0.63%) 0.75s (± 0.69%) +0.00s (+ 0.13%) 0.74s 0.77s
Check Time 5.47s (± 0.67%) 5.49s (± 0.52%) +0.02s (+ 0.42%) 5.43s 5.57s
Emit Time 3.22s (± 0.81%) 3.21s (± 0.98%) -0.01s (- 0.40%) 3.15s 3.29s
Total Time 10.92s (± 0.38%) 10.93s (± 0.20%) +0.01s (+ 0.12%) 10.87s 10.96s
TFS - node (v10.16.3, x64)
Memory used 305,534k (± 0.02%) 305,577k (± 0.02%) +43k (+ 0.01%) 305,438k 305,713k
Parse Time 1.20s (± 0.50%) 1.19s (± 0.50%) -0.00s (- 0.17%) 1.18s 1.21s
Bind Time 0.71s (± 0.63%) 0.71s (± 0.81%) +0.00s (+ 0.28%) 0.70s 0.72s
Check Time 5.00s (± 0.59%) 5.01s (± 0.40%) +0.01s (+ 0.26%) 4.95s 5.05s
Emit Time 3.36s (± 1.17%) 3.39s (± 0.94%) +0.03s (+ 0.89%) 3.31s 3.45s
Total Time 10.26s (± 0.58%) 10.30s (± 0.33%) +0.04s (+ 0.39%) 10.23s 10.40s
material-ui - node (v10.16.3, x64)
Memory used 471,381k (± 0.01%) 472,110k (± 0.01%) +729k (+ 0.15%) 471,974k 472,207k
Parse Time 1.78s (± 0.26%) 1.78s (± 0.42%) -0.00s (- 0.17%) 1.76s 1.80s
Bind Time 0.66s (± 1.13%) 0.66s (± 0.88%) -0.01s (- 0.90%) 0.65s 0.67s
Check Time 14.21s (± 0.54%) 14.22s (± 0.76%) +0.00s (+ 0.03%) 14.03s 14.52s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 16.66s (± 0.46%) 16.65s (± 0.70%) -0.00s (- 0.00%) 16.45s 16.99s
xstate - node (v10.16.3, x64)
Memory used 568,980k (± 0.02%) 569,823k (± 0.02%) +843k (+ 0.15%) 569,611k 570,077k
Parse Time 2.56s (± 0.34%) 2.55s (± 0.26%) -0.01s (- 0.31%) 2.54s 2.57s
Bind Time 1.01s (± 0.47%) 1.01s (± 0.55%) +0.00s (+ 0.10%) 1.00s 1.02s
Check Time 1.49s (± 0.66%) 1.51s (± 0.46%) +0.02s (+ 1.14%) 1.49s 1.52s
Emit Time 0.07s (± 3.14%) 0.07s (± 0.00%) -0.00s (- 1.41%) 0.07s 0.07s
Total Time 5.12s (± 0.32%) 5.13s (± 0.29%) +0.01s (+ 0.21%) 5.10s 5.16s
Angular - node (v12.1.0, x64)
Memory used 332,458k (± 0.02%) 334,564k (± 0.03%) +2,106k (+ 0.63%) 334,329k 334,830k
Parse Time 1.94s (± 0.55%) 1.94s (± 0.54%) +0.00s (+ 0.10%) 1.91s 1.96s
Bind Time 0.81s (± 0.61%) 0.82s (± 0.49%) +0.01s (+ 0.61%) 0.81s 0.83s
Check Time 5.28s (± 0.42%) 5.34s (± 0.57%) +0.06s (+ 1.10%) 5.26s 5.40s
Emit Time 6.08s (± 0.37%) 6.15s (± 0.49%) +0.07s (+ 1.12%) 6.09s 6.22s
Total Time 14.11s (± 0.25%) 14.25s (± 0.22%) +0.13s (+ 0.94%) 14.18s 14.32s
Compiler-Unions - node (v12.1.0, x64)
Memory used 191,471k (± 0.10%) 190,211k (± 0.40%) -1,260k (- 0.66%) 187,187k 190,781k
Parse Time 0.78s (± 0.97%) 0.78s (± 0.94%) -0.01s (- 0.77%) 0.76s 0.79s
Bind Time 0.53s (± 1.29%) 0.53s (± 0.89%) +0.01s (+ 1.33%) 0.52s 0.54s
Check Time 7.28s (± 0.61%) 7.34s (± 0.75%) +0.06s (+ 0.80%) 7.22s 7.46s
Emit Time 2.47s (± 0.87%) 2.48s (± 0.81%) +0.00s (+ 0.04%) 2.44s 2.52s
Total Time 11.07s (± 0.54%) 11.13s (± 0.52%) +0.06s (+ 0.56%) 11.01s 11.27s
Monaco - node (v12.1.0, x64)
Memory used 325,547k (± 0.03%) 325,519k (± 0.02%) -28k (- 0.01%) 325,308k 325,677k
Parse Time 1.46s (± 0.63%) 1.47s (± 0.57%) +0.01s (+ 0.62%) 1.45s 1.49s
Bind Time 0.72s (± 0.69%) 0.73s (± 0.76%) +0.01s (+ 0.97%) 0.72s 0.74s
Check Time 5.32s (± 0.52%) 5.36s (± 0.58%) +0.04s (+ 0.68%) 5.29s 5.42s
Emit Time 3.21s (± 0.58%) 3.24s (± 0.88%) +0.03s (+ 1.06%) 3.19s 3.31s
Total Time 10.72s (± 0.27%) 10.80s (± 0.43%) +0.09s (+ 0.79%) 10.70s 10.92s
TFS - node (v12.1.0, x64)
Memory used 290,300k (± 0.02%) 290,284k (± 0.02%) -16k (- 0.01%) 290,129k 290,388k
Parse Time 1.21s (± 0.81%) 1.23s (± 1.03%) +0.02s (+ 1.57%) 1.20s 1.25s
Bind Time 0.69s (± 0.72%) 0.70s (± 1.07%) +0.01s (+ 1.60%) 0.68s 0.72s
Check Time 4.92s (± 0.33%) 4.94s (± 0.53%) +0.02s (+ 0.49%) 4.87s 4.99s
Emit Time 3.39s (± 1.02%) 3.39s (± 0.49%) -0.00s (- 0.09%) 3.36s 3.44s
Total Time 10.21s (± 0.32%) 10.26s (± 0.35%) +0.06s (+ 0.55%) 10.18s 10.33s
material-ui - node (v12.1.0, x64)
Memory used 449,859k (± 0.08%) 450,862k (± 0.01%) +1,002k (+ 0.22%) 450,724k 450,960k
Parse Time 1.77s (± 0.35%) 1.80s (± 0.62%) +0.03s (+ 1.41%) 1.77s 1.83s
Bind Time 0.64s (± 0.70%) 0.65s (± 1.12%) +0.01s (+ 1.57%) 0.63s 0.66s
Check Time 12.71s (± 0.73%) 12.90s (± 0.74%) +0.18s (+ 1.44%) 12.62s 13.09s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.12s (± 0.61%) 15.34s (± 0.62%) +0.22s (+ 1.43%) 15.06s 15.54s
xstate - node (v12.1.0, x64)
Memory used 534,952k (± 0.02%) 539,370k (± 1.49%) +4,419k (+ 0.83%) 535,607k 571,930k
Parse Time 2.49s (± 0.66%) 2.51s (± 0.50%) +0.02s (+ 0.80%) 2.48s 2.53s
Bind Time 1.03s (± 0.63%) 1.05s (± 0.63%) +0.02s (+ 1.74%) 1.03s 1.06s
Check Time 1.43s (± 0.35%) 1.47s (± 1.12%) +0.04s (+ 3.02%) 1.43s 1.51s
Emit Time 0.07s (± 0.00%) 0.07s (± 0.00%) 0.00s ( 0.00%) 0.07s 0.07s
Total Time 5.01s (± 0.28%) 5.09s (± 0.39%) +0.08s (+ 1.70%) 5.05s 5.14s
Angular - node (v14.15.1, x64)
Memory used 330,877k (± 0.01%) 332,720k (± 0.13%) +1,843k (+ 0.56%) 330,915k 332,949k
Parse Time 1.94s (± 0.33%) 1.94s (± 0.44%) -0.00s (- 0.15%) 1.92s 1.96s
Bind Time 0.86s (± 0.72%) 0.86s (± 0.81%) +0.00s (+ 0.23%) 0.85s 0.88s
Check Time 5.36s (± 0.33%) 5.42s (± 0.65%) +0.05s (+ 0.97%) 5.34s 5.49s
Emit Time 6.18s (± 0.48%) 6.22s (± 0.67%) +0.04s (+ 0.65%) 6.13s 6.32s
Total Time 14.34s (± 0.30%) 14.43s (± 0.42%) +0.08s (+ 0.59%) 14.31s 14.60s
Compiler-Unions - node (v14.15.1, x64)
Memory used 191,777k (± 0.63%) 192,153k (± 0.36%) +376k (+ 0.20%) 189,377k 192,511k
Parse Time 0.81s (± 0.59%) 0.81s (± 0.76%) +0.00s (+ 0.25%) 0.80s 0.82s
Bind Time 0.55s (± 0.60%) 0.55s (± 0.66%) +0.00s (+ 0.73%) 0.55s 0.56s
Check Time 7.34s (± 0.59%) 7.41s (± 0.70%) +0.07s (+ 0.91%) 7.29s 7.54s
Emit Time 2.47s (± 1.06%) 2.47s (± 0.60%) -0.01s (- 0.28%) 2.42s 2.49s
Total Time 11.17s (± 0.48%) 11.23s (± 0.54%) +0.07s (+ 0.58%) 11.07s 11.38s
Monaco - node (v14.15.1, x64)
Memory used 324,317k (± 0.01%) 324,341k (± 0.01%) +24k (+ 0.01%) 324,291k 324,380k
Parse Time 1.50s (± 0.45%) 1.51s (± 0.60%) +0.01s (+ 0.40%) 1.49s 1.53s
Bind Time 0.75s (± 0.48%) 0.76s (± 0.99%) +0.01s (+ 1.33%) 0.75s 0.78s
Check Time 5.27s (± 0.71%) 5.28s (± 0.54%) +0.01s (+ 0.27%) 5.21s 5.36s
Emit Time 3.24s (± 0.61%) 3.26s (± 0.98%) +0.02s (+ 0.68%) 3.21s 3.34s
Total Time 10.77s (± 0.50%) 10.82s (± 0.52%) +0.05s (+ 0.51%) 10.67s 10.97s
TFS - node (v14.15.1, x64)
Memory used 289,184k (± 0.01%) 289,167k (± 0.01%) -17k (- 0.01%) 289,130k 289,206k
Parse Time 1.23s (± 0.61%) 1.23s (± 0.86%) +0.01s (+ 0.57%) 1.21s 1.25s
Bind Time 0.73s (± 0.64%) 0.73s (± 0.64%) +0.00s (+ 0.00%) 0.72s 0.74s
Check Time 4.92s (± 0.60%) 4.90s (± 0.32%) -0.01s (- 0.28%) 4.86s 4.92s
Emit Time 3.48s (± 1.28%) 3.46s (± 1.37%) -0.02s (- 0.46%) 3.28s 3.52s
Total Time 10.35s (± 0.48%) 10.33s (± 0.49%) -0.02s (- 0.20%) 10.15s 10.40s
material-ui - node (v14.15.1, x64)
Memory used 448,345k (± 0.01%) 449,031k (± 0.06%) +685k (+ 0.15%) 448,004k 449,211k
Parse Time 1.83s (± 0.41%) 1.83s (± 0.38%) +0.00s (+ 0.05%) 1.82s 1.85s
Bind Time 0.68s (± 0.50%) 0.68s (± 0.73%) -0.00s (- 0.15%) 0.67s 0.69s
Check Time 12.72s (± 0.32%) 12.83s (± 0.61%) +0.11s (+ 0.87%) 12.65s 13.02s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.22s (± 0.25%) 15.33s (± 0.51%) +0.11s (+ 0.72%) 15.16s 15.54s
xstate - node (v14.15.1, x64)
Memory used 532,767k (± 0.01%) 533,641k (± 0.00%) +874k (+ 0.16%) 533,597k 533,679k
Parse Time 2.54s (± 0.23%) 2.56s (± 0.47%) +0.02s (+ 0.83%) 2.53s 2.59s
Bind Time 1.15s (± 0.96%) 1.15s (± 1.06%) -0.00s (- 0.43%) 1.12s 1.18s
Check Time 1.47s (± 0.46%) 1.50s (± 0.50%) +0.02s (+ 1.56%) 1.48s 1.52s
Emit Time 0.07s (± 0.00%) 0.07s (± 0.00%) 0.00s ( 0.00%) 0.07s 0.07s
Total Time 5.24s (± 0.25%) 5.28s (± 0.38%) +0.04s (+ 0.78%) 5.25s 5.32s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-210-generic
Architecturex64
Available Memory16 GB
Available Memory12 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)
  • xstate - node (v10.16.3, x64)
  • xstate - node (v12.1.0, x64)
  • xstate - node (v14.15.1, x64)
Benchmark Name Iterations
Current 46781 10
Baseline main 10

Developer Information:

Download Benchmark

@DetachHead
Copy link
Contributor Author

i think i know how to fix the downstream errors, will give it a go

@DetachHead
Copy link
Contributor Author

will the bot listen to me?

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

@andrewbranch
Copy link
Member

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 16, 2021

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 16, 2021

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 16, 2021

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

@andrewbranch
The results of the user tests run you requested are in!

Here they are:

Comparison Report - main..refs/pull/46781/merge

[adonis-framework]

1 of 1 projects failed to build with the old tsc

/mnt/ts_downloads/adonis-framework/tsconfig.json

  • error TS2740: Type '() => {}[]' is missing the following properties from type 'any[]': pop, push, reverse, shift, and 28 more.
    • /mnt/ts_downloads/adonis-framework/node_modules/adonis-framework/src/Event/index.js(128,12)

[bcryptjs]

1 of 1 projects failed to build with the old tsc

/mnt/ts_downloads/bcryptjs/tsconfig.json

  • error TS2740: Type 'Buffer' is missing the following properties from type 'number[]': pop, push, shift, splice, and 5 more.
    • /mnt/ts_downloads/bcryptjs/node_modules/bcryptjs/src/bcrypt.js(25,13)

[lodash]

1 of 1 projects failed to build with the old tsc

/mnt/ts_downloads/lodash/tsconfig.json

  • error TS2740: Type 'SetCache' is missing the following properties from type 'any[]': length, pop, reverse, shift, and 28 more.
    • /mnt/ts_downloads/lodash/node_modules/lodash/_baseDifference.js(43,5)

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - main..46781

Metric main 46781 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 354,582k (± 0.02%) 356,532k (± 0.01%) +1,950k (+ 0.55%) 356,457k 356,663k
Parse Time 1.97s (± 1.45%) 1.95s (± 0.71%) -0.02s (- 1.07%) 1.92s 1.98s
Bind Time 0.84s (± 0.81%) 0.85s (± 1.20%) +0.00s (+ 0.47%) 0.83s 0.88s
Check Time 5.49s (± 0.53%) 5.50s (± 0.50%) +0.01s (+ 0.15%) 5.44s 5.57s
Emit Time 5.92s (± 1.00%) 5.88s (± 0.39%) -0.05s (- 0.78%) 5.85s 5.94s
Total Time 14.23s (± 0.52%) 14.17s (± 0.23%) -0.06s (- 0.44%) 14.11s 14.24s
Compiler-Unions - node (v10.16.3, x64)
Memory used 203,738k (± 0.29%) 205,676k (± 0.05%) +1,937k (+ 0.95%) 205,523k 205,915k
Parse Time 0.78s (± 1.35%) 0.78s (± 0.43%) -0.00s (- 0.64%) 0.77s 0.79s
Bind Time 0.53s (± 1.10%) 0.52s (± 1.13%) -0.00s (- 0.57%) 0.51s 0.53s
Check Time 7.85s (± 0.69%) 7.83s (± 0.70%) -0.02s (- 0.22%) 7.73s 8.00s
Emit Time 2.47s (± 0.76%) 2.47s (± 0.69%) +0.01s (+ 0.20%) 2.45s 2.51s
Total Time 11.63s (± 0.52%) 11.61s (± 0.54%) -0.02s (- 0.19%) 11.50s 11.81s
Monaco - node (v10.16.3, x64)
Memory used 342,455k (± 0.02%) 342,438k (± 0.03%) -17k (- 0.00%) 342,294k 342,670k
Parse Time 1.50s (± 1.58%) 1.48s (± 0.57%) -0.02s (- 1.40%) 1.45s 1.50s
Bind Time 0.74s (± 0.80%) 0.75s (± 0.87%) +0.00s (+ 0.54%) 0.74s 0.76s
Check Time 5.47s (± 0.56%) 5.46s (± 0.66%) -0.01s (- 0.20%) 5.37s 5.51s
Emit Time 3.20s (± 0.69%) 3.21s (± 1.14%) +0.01s (+ 0.22%) 3.16s 3.33s
Total Time 10.91s (± 0.50%) 10.89s (± 0.47%) -0.02s (- 0.16%) 10.81s 11.08s
TFS - node (v10.16.3, x64)
Memory used 305,565k (± 0.01%) 305,577k (± 0.02%) +12k (+ 0.00%) 305,390k 305,682k
Parse Time 1.20s (± 0.72%) 1.19s (± 0.63%) -0.01s (- 0.67%) 1.18s 1.21s
Bind Time 0.71s (± 0.70%) 0.71s (± 0.47%) -0.01s (- 0.70%) 0.70s 0.72s
Check Time 4.99s (± 0.44%) 5.01s (± 0.52%) +0.02s (+ 0.42%) 4.94s 5.05s
Emit Time 3.32s (± 0.91%) 3.40s (± 1.49%) +0.08s (+ 2.41%) 3.31s 3.52s
Total Time 10.23s (± 0.39%) 10.31s (± 0.59%) +0.09s (+ 0.86%) 10.21s 10.47s
material-ui - node (v10.16.3, x64)
Memory used 471,347k (± 0.01%) 472,125k (± 0.01%) +778k (+ 0.17%) 471,940k 472,219k
Parse Time 1.79s (± 2.73%) 1.78s (± 0.47%) -0.02s (- 1.00%) 1.76s 1.79s
Bind Time 0.66s (± 0.91%) 0.66s (± 0.61%) +0.01s (+ 0.92%) 0.65s 0.67s
Check Time 14.15s (± 0.44%) 14.20s (± 0.56%) +0.05s (+ 0.36%) 14.05s 14.39s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 16.60s (± 0.42%) 16.64s (± 0.51%) +0.04s (+ 0.24%) 16.48s 16.82s
xstate - node (v10.16.3, x64)
Memory used 569,007k (± 0.02%) 569,716k (± 0.02%) +709k (+ 0.12%) 569,468k 569,922k
Parse Time 2.56s (± 0.74%) 2.55s (± 0.48%) -0.01s (- 0.27%) 2.52s 2.57s
Bind Time 1.01s (± 0.49%) 1.01s (± 0.57%) +0.00s (+ 0.40%) 1.00s 1.03s
Check Time 1.49s (± 0.32%) 1.52s (± 0.45%) +0.02s (+ 1.54%) 1.50s 1.53s
Emit Time 0.07s (± 0.00%) 0.07s (± 0.00%) 0.00s ( 0.00%) 0.07s 0.07s
Total Time 5.12s (± 0.37%) 5.14s (± 0.34%) +0.02s (+ 0.37%) 5.10s 5.18s
Angular - node (v12.1.0, x64)
Memory used 332,458k (± 0.01%) 334,483k (± 0.03%) +2,025k (+ 0.61%) 334,236k 334,602k
Parse Time 1.94s (± 0.80%) 1.95s (± 0.86%) +0.01s (+ 0.31%) 1.92s 2.00s
Bind Time 0.82s (± 0.61%) 0.82s (± 0.91%) +0.00s (+ 0.25%) 0.80s 0.83s
Check Time 5.32s (± 0.47%) 5.33s (± 0.38%) +0.01s (+ 0.24%) 5.28s 5.39s
Emit Time 6.17s (± 0.62%) 6.14s (± 0.49%) -0.03s (- 0.47%) 6.06s 6.20s
Total Time 14.25s (± 0.40%) 14.24s (± 0.33%) -0.01s (- 0.08%) 14.15s 14.35s
Compiler-Unions - node (v12.1.0, x64)
Memory used 191,577k (± 0.03%) 193,250k (± 0.08%) +1,673k (+ 0.87%) 192,729k 193,523k
Parse Time 0.78s (± 0.46%) 0.78s (± 0.86%) -0.01s (- 0.89%) 0.76s 0.79s
Bind Time 0.54s (± 0.69%) 0.53s (± 1.37%) -0.00s (- 0.56%) 0.52s 0.55s
Check Time 7.38s (± 0.62%) 7.33s (± 0.49%) -0.06s (- 0.79%) 7.27s 7.44s
Emit Time 2.48s (± 1.21%) 2.49s (± 0.62%) +0.01s (+ 0.28%) 2.47s 2.54s
Total Time 11.18s (± 0.47%) 11.12s (± 0.40%) -0.07s (- 0.58%) 11.04s 11.25s
Monaco - node (v12.1.0, x64)
Memory used 325,552k (± 0.03%) 325,597k (± 0.04%) +45k (+ 0.01%) 325,348k 325,995k
Parse Time 1.48s (± 1.06%) 1.46s (± 0.89%) -0.02s (- 1.35%) 1.44s 1.50s
Bind Time 0.73s (± 1.11%) 0.73s (± 0.91%) 0.00s ( 0.00%) 0.72s 0.75s
Check Time 5.35s (± 0.43%) 5.34s (± 0.49%) -0.01s (- 0.19%) 5.27s 5.39s
Emit Time 3.23s (± 0.64%) 3.22s (± 0.71%) -0.01s (- 0.37%) 3.18s 3.28s
Total Time 10.79s (± 0.46%) 10.75s (± 0.39%) -0.04s (- 0.39%) 10.67s 10.85s
TFS - node (v12.1.0, x64)
Memory used 290,337k (± 0.03%) 290,254k (± 0.01%) -83k (- 0.03%) 290,200k 290,335k
Parse Time 1.23s (± 0.53%) 1.21s (± 0.48%) -0.02s (- 1.47%) 1.20s 1.22s
Bind Time 0.70s (± 0.99%) 0.69s (± 1.09%) -0.00s (- 0.00%) 0.68s 0.71s
Check Time 4.95s (± 0.45%) 4.93s (± 0.49%) -0.03s (- 0.55%) 4.88s 4.97s
Emit Time 3.39s (± 1.00%) 3.38s (± 0.88%) -0.00s (- 0.12%) 3.30s 3.46s
Total Time 10.26s (± 0.36%) 10.21s (± 0.41%) -0.05s (- 0.48%) 10.11s 10.32s
material-ui - node (v12.1.0, x64)
Memory used 450,127k (± 0.01%) 450,778k (± 0.07%) +650k (+ 0.14%) 449,568k 451,073k
Parse Time 1.80s (± 0.40%) 1.78s (± 0.63%) -0.02s (- 1.06%) 1.76s 1.81s
Bind Time 0.65s (± 0.76%) 0.64s (± 1.62%) -0.00s (- 0.62%) 0.63s 0.67s
Check Time 12.85s (± 0.54%) 12.74s (± 0.75%) -0.11s (- 0.84%) 12.64s 13.01s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.29s (± 0.48%) 15.16s (± 0.73%) -0.13s (- 0.83%) 15.05s 15.46s
xstate - node (v12.1.0, x64)
Memory used 535,022k (± 0.01%) 535,782k (± 0.02%) +760k (+ 0.14%) 535,528k 536,044k
Parse Time 2.51s (± 0.34%) 2.49s (± 0.31%) -0.03s (- 1.04%) 2.47s 2.50s
Bind Time 1.05s (± 0.76%) 1.03s (± 0.71%) -0.02s (- 1.90%) 1.02s 1.05s
Check Time 1.43s (± 0.73%) 1.45s (± 0.68%) +0.02s (+ 1.33%) 1.44s 1.47s
Emit Time 0.07s (± 0.00%) 0.07s (± 0.00%) 0.00s ( 0.00%) 0.07s 0.07s
Total Time 5.06s (± 0.29%) 5.04s (± 0.33%) -0.03s (- 0.51%) 5.00s 5.07s
Angular - node (v14.15.1, x64)
Memory used 330,897k (± 0.01%) 332,908k (± 0.01%) +2,011k (+ 0.61%) 332,857k 332,994k
Parse Time 1.94s (± 0.39%) 1.93s (± 0.55%) -0.00s (- 0.10%) 1.91s 1.96s
Bind Time 0.86s (± 0.55%) 0.86s (± 0.82%) -0.00s (- 0.12%) 0.85s 0.87s
Check Time 5.40s (± 0.46%) 5.40s (± 0.48%) +0.00s (+ 0.06%) 5.35s 5.47s
Emit Time 6.23s (± 0.59%) 6.17s (± 0.70%) -0.06s (- 1.01%) 6.11s 6.29s
Total Time 14.43s (± 0.36%) 14.37s (± 0.47%) -0.06s (- 0.43%) 14.27s 14.57s
Compiler-Unions - node (v14.15.1, x64)
Memory used 192,111k (± 0.59%) 192,814k (± 0.56%) +704k (+ 0.37%) 191,839k 195,122k
Parse Time 0.80s (± 0.61%) 0.81s (± 0.74%) +0.00s (+ 0.25%) 0.80s 0.82s
Bind Time 0.55s (± 0.67%) 0.55s (± 0.41%) -0.01s (- 1.08%) 0.54s 0.55s
Check Time 7.40s (± 0.49%) 7.40s (± 0.33%) -0.00s (- 0.04%) 7.35s 7.46s
Emit Time 2.48s (± 1.06%) 2.47s (± 0.51%) -0.01s (- 0.60%) 2.45s 2.50s
Total Time 11.24s (± 0.48%) 11.22s (± 0.24%) -0.02s (- 0.17%) 11.16s 11.28s
Monaco - node (v14.15.1, x64)
Memory used 324,326k (± 0.00%) 324,339k (± 0.00%) +13k (+ 0.00%) 324,320k 324,372k
Parse Time 1.51s (± 0.92%) 1.51s (± 0.82%) -0.00s (- 0.20%) 1.49s 1.54s
Bind Time 0.76s (± 0.77%) 0.75s (± 0.63%) -0.00s (- 0.53%) 0.74s 0.76s
Check Time 5.28s (± 0.41%) 5.26s (± 0.20%) -0.01s (- 0.21%) 5.24s 5.28s
Emit Time 3.24s (± 0.49%) 3.22s (± 0.71%) -0.01s (- 0.43%) 3.18s 3.29s
Total Time 10.78s (± 0.38%) 10.74s (± 0.20%) -0.04s (- 0.36%) 10.70s 10.79s
TFS - node (v14.15.1, x64)
Memory used 289,164k (± 0.01%) 289,167k (± 0.01%) +4k (+ 0.00%) 289,123k 289,196k
Parse Time 1.24s (± 0.72%) 1.23s (± 0.63%) -0.01s (- 0.57%) 1.22s 1.25s
Bind Time 0.73s (± 0.65%) 0.72s (± 0.51%) -0.01s (- 1.09%) 0.72s 0.73s
Check Time 4.93s (± 0.57%) 4.92s (± 0.45%) -0.02s (- 0.34%) 4.86s 4.97s
Emit Time 3.50s (± 0.99%) 3.49s (± 1.56%) -0.01s (- 0.34%) 3.28s 3.57s
Total Time 10.40s (± 0.44%) 10.35s (± 0.55%) -0.04s (- 0.43%) 10.15s 10.44s
material-ui - node (v14.15.1, x64)
Memory used 448,355k (± 0.00%) 449,143k (± 0.01%) +788k (+ 0.18%) 449,088k 449,233k
Parse Time 1.83s (± 0.52%) 1.82s (± 0.42%) -0.00s (- 0.11%) 1.81s 1.84s
Bind Time 0.68s (± 0.69%) 0.68s (± 0.54%) -0.00s (- 0.59%) 0.67s 0.68s
Check Time 12.86s (± 0.50%) 12.78s (± 0.47%) -0.08s (- 0.61%) 12.65s 12.93s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 15.36s (± 0.42%) 15.28s (± 0.41%) -0.08s (- 0.54%) 15.13s 15.43s
xstate - node (v14.15.1, x64)
Memory used 532,757k (± 0.01%) 533,649k (± 0.00%) +892k (+ 0.17%) 533,602k 533,682k
Parse Time 2.55s (± 0.43%) 2.54s (± 0.33%) -0.01s (- 0.24%) 2.52s 2.56s
Bind Time 1.15s (± 1.13%) 1.14s (± 0.98%) -0.01s (- 0.87%) 1.12s 1.17s
Check Time 1.48s (± 0.57%) 1.50s (± 0.47%) +0.02s (+ 1.35%) 1.49s 1.52s
Emit Time 0.07s (± 0.00%) 0.07s (± 0.00%) 0.00s ( 0.00%) 0.07s 0.07s
Total Time 5.25s (± 0.43%) 5.26s (± 0.30%) +0.01s (+ 0.19%) 5.22s 5.29s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-210-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 (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)
  • xstate - node (v10.16.3, x64)
  • xstate - node (v12.1.0, x64)
  • xstate - node (v14.15.1, x64)
Benchmark Name Iterations
Current 46781 10
Baseline main 10

Developer Information:

Download Benchmark

@DetachHead
Copy link
Contributor Author

so i fixed it by using the this type for the third argument in map, foeEach, etc. but it looks like some definitelytyped packages need to be updated with the same thing. it doesn't look like too much effort and i think it's a worthwhile change as it more accurately describes what that argument actually is.

i'll make a PR to definitelytyped with this change later today and link it here

@andrewbranch
Copy link
Member

My biggest concern right now is that it might be confusing to some users for the quick info / errors for every common Array method to reference ReadonlyArray when that’s not what they were using. I wonder if it would be better to leave all the method declarations duplicated.

@DetachHead
Copy link
Contributor Author

DetachHead commented Nov 17, 2021

i personally don't think that's an issue. most other languages have a base "collection" or "iterable" interface that mutable arrays extend.

i'd argue that it's far more confusing now than it would be after this change. currently it's difficult to even tell if Array extends ReadonlyArray, which is something i feel should be very obvious to the user (it also helps in gaining a more thorough understanding of the language's "type hierarchy")

currently the only way to find out is by attempting to use an Array as a ReadonlyArray, which works, but leads to confusion/misconceptions as to why. i understand that this sort of thing can come with the territory of a structurally typed language, but i think we should still attempt to keep the "hierarchy" clear and easy to follow by explicitly stating when one type extends another, where possible

however if you think the name ReadonlyArray can be a source of confusion what about making a BaseArray interface that both ReadonlyArray and Array extend?

interface BaseArray<T> {
    map<U>(callbackfn: (value: T, index: number, array: this) => U, thisArg?: any): U[];
    filter<S extends T>(predicate: (value: T, index: number, array: this) => value is S, thisArg?: any): S[];
    //...
}

export interface ReadonlyArray<T> extends BaseArray<T> {
    //nothing to see here
}

export interface Array<T> extends ReadonlyArray<T> {
    push(...items: T[]): number;
    //...
}

@DetachHead DetachHead changed the title make Array explicitly extend ReadonlyArray make Array explicitly extend ReadonlyArray and use this type in the callbacks Nov 19, 2021
@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Dec 9, 2021

I know this PR is slightly different, but it reminds me of a change from a few years ago (#12784) that we had to revert (#16223) due to performance considerations.

@DetachHead
Copy link
Contributor Author

@DanielRosenwasser i ran the same command mentioned in that PR with and without my change, and as far as i can tell there doesn't seem to be much of a difference:

before:

> node built\local\tsc.js --diagnostics --p src\compiler\tsconfig.json
Files:              159
Lines:           193790
Nodes:           850289
Identifiers:     342479
Symbols:         196136
Types:            82506
Instantiations:  158176
Memory used:    529714K
I/O read:         0.06s
I/O write:        0.06s
Parse time:       2.69s
Bind time:        1.68s
Check time:      11.74s
Emit time:        6.30s
Total time:      22.41s

after:

> node built\local\tsc.js --diagnostics --p src\compiler\tsconfig.json
Files:              159
Lines:           193790
Nodes:           850289
Identifiers:     342479
Symbols:         196136
Types:            82506
Instantiations:  158176
Memory used:    546690K
I/O read:         0.05s
I/O write:        0.07s
Parse time:       2.29s
Bind time:        1.49s
Check time:      12.10s
Emit time:        6.25s
Total time:      22.13s

(disclaimer: my PC is not good and it was difficult to get consistent results)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Experiment A fork with an experimental idea which might not make it into master For Uncommitted Bug PR for untriaged, rejected, closed or missing bug lib update PR modifies files in the `lib` folder
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Array should extend ReadonlyArray
4 participants