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

Improve signature assignability for argument lists of different lengths #49218

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

Conversation

Andarist
Copy link
Contributor

@Andarist Andarist commented May 23, 2022

fixes #48663
fixes #45972
fixes #56766

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label May 23, 2022
src/compiler/checker.ts Outdated Show resolved Hide resolved
src/compiler/checker.ts Outdated Show resolved Hide resolved
Source has 2 element(s) but target allows only 1.
Type '[string] | [number]' is not assignable to type '[y: string]'.
Type '[number]' is not assignable to type '[y: string]'.
Type 'number' is not assignable to type 'string'.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To the best of my understanding, this change is correct and welcome under the implemented changes.

@graphemecluster
Copy link
Contributor

I've been working on a library that's been plagued by #48663, so I'm really happy to see this PR.
And will #45972 be fixed by this PR as well?

@Andarist
Copy link
Contributor Author

And will #45972 be fixed by this PR as well?

Not yet - but I think it has the potential to do that. I intentionally didn't handle this case yet because I wasn't sure how to properly "expand" the target type to a fixed-size tuple. I've mentioned this in the comment here

@Andarist
Copy link
Contributor Author

Actually, my simplistic "expand" idea wouldn't work with leading/middle rest elements. However, one could write a correct logic based on the code here:
https://github.dev/microsoft/TypeScript/blob/18193973fec66716b1489d3edeeb4a3c837bd39f/src/compiler/checker.ts#L20128-L20198

It is a little bit convoluted though, gonna continue looking into this.

@graphemecluster

This comment was marked as off-topic.

@Andarist
Copy link
Contributor Author

That is definitely out of the scope of this PR. I don't intend to work on something like this - also, once you start involving generics in this then unions and overloads might stop being the same. Union means one of the members - any member, it's order-independent. OTOH, overloads are always matched from the top to the bottom so the first match "wins".

@graphemecluster

This comment was marked as outdated.

@graphemecluster
Copy link
Contributor

graphemecluster commented May 29, 2022

I think the easiest way to solve all the related issues is to wrap all the arguments into a tuple with rest syntax, i.e. item => {} should become (...[item]) => {} and ([first, ...rest], foo, ...args) => {} should work just like (...[[first, ...rest], foo, ...args]) => {}.

I think I misunderstood the mechanism before as wrapping the arguments just affects the inference part. See #45972 (comment).


I just look though the checker and wonder why isTupleType doesn't check for union and intersection types. (Even if it does, it still can't fix #45972 though)

@Andarist Andarist force-pushed the fix/rest-tuple-union-shorter-contextual-params branch from f7feca5 to 88027d5 Compare December 28, 2022 16:10
Comment on lines +80 to +83
!!! error TS2322: Type '[number, boolean] | [string, undefined]' is not assignable to type '[y: number, z: boolean]'.
!!! error TS2322: Type '[string, undefined]' is not assignable to type '[y: number, z: boolean]'.
!!! error TS2322: Type at position 0 in source is not compatible with type at position 0 in target.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error change comes from the fact that I fill the slice of the target type with undefineds here (when it's shorter than the source's slice):
https://github.dev/microsoft/TypeScript/blob/6c5383d701417e8a98398b4171af0f201ee593c5/src/compiler/checker.ts#L19394-L19402

I think this is a good change. This will allow more patterns to be assignable, especially with target signatures using unions of tuples for their rest parameter. After all, the implementation is free to ignore any of the provided arguments etc. This is also already just fine in TS:

declare let f1: (a: string) => void
declare let f2: (a: string, b: number) => void

f2 = f1

And since this is OK I think that this one should be too:

declare let f1: (x: string, ...args: [string] | [number, boolean]) => void;

// Type '(a: string, b: string | number, c: boolean | undefined) => void' is not assignable to type '(x: string, ...args: [string] | [number, boolean]) => void'.
//   Types of parameters 'b' and 'args' are incompatible.
//     Type '[string] | [number, boolean]' is not assignable to type '[b: string | number, c: boolean | undefined]'.
//       Type '[string]' is not assignable to type '[b: string | number, c: boolean | undefined]'.
//         Source has 1 element(s) but target requires 2.
f1 = (a, b, c) => {}

So with this change that caused this particular error here to be reported differently we now allow the example above and I added a test case for it:

const f2: (x: string, ...args: [string] | [number, boolean]) => void = (a, b, c) => {};

Comment on lines +73 to +75
!!! error TS2322: Type '[string] | [number]' is not assignable to type '[y: string]'.
!!! error TS2322: Type '[number]' is not assignable to type '[y: string]'.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a change of the error for this case:

declare let f1: (x: string, ...args: [string] | [number, boolean]) => void;
declare let f2: (x: string, y: string) => void;

f1 = f2

With the current changes in this PR, I create a slice from the target tuple and I cap it to the source's length~. I do that for similar reasons that I've outlined in the other comment. The source signature can freely ignore the "extra" arguments so we don't even need to check them here (we'd have to ignore them through some other mechanism anyway)

@Andarist
Copy link
Contributor Author

@jcalz this PR implements changes for the problem that you have noticed here. I pushed out tests for those cases in this commit

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 9, 2024

Heya @gabritto, I've started to run the regular perf test suite on this PR at 608f7c3. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

@gabritto Here are the results of running the user test suite comparing main and refs/pull/49218/merge:

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Package install failed"

Otherwise...

Something interesting changed - please have a look.

Details

puppeteer

packages/browsers/test/src/tsconfig.json

@typescript-bot
Copy link
Collaborator

Hey @gabritto, the results of running the DT tests are ready.
Everything looks the same!
You can check the log here.

@typescript-bot
Copy link
Collaborator

@gabritto Here are the results of running the top-repos suite comparing main and refs/pull/49218/merge:

Something interesting changed - please have a look.

Details

chakra-ui/chakra-ui

4 of 28 projects failed to build with the old tsc and were ignored

packages/components/tsconfig.build.json

  • error TS5056: Cannot write file '/mnt/ts_downloads/chakra-ui/packages/components/dist/types/menu/menu.stories.d.ts' because it would be overwritten by multiple input files.
    • Project Scope

@typescript-bot
Copy link
Collaborator

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

Here they are:

startup

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
tsc-startup - node (v18.15.0, x64)
Execution time 153.85ms (± 0.21%) 153.91ms (± 0.20%) +0.06ms (+ 0.04%) 152.76ms 158.03ms p=0.014 n=600
tsserver-startup - node (v18.15.0, x64)
Execution time 229.28ms (± 0.13%) 229.27ms (± 0.17%) -0.02ms (- 0.01%) 227.93ms 234.36ms p=0.021 n=600
tsserverlibrary-startup - node (v18.15.0, x64)
Execution time 230.90ms (± 0.18%) 230.87ms (± 0.21%) ~ 229.16ms 238.22ms p=0.226 n=600
typescript-startup - node (v18.15.0, x64)
Execution time 230.92ms (± 0.20%) 230.81ms (± 0.19%) -0.11ms (- 0.05%) 229.01ms 236.49ms p=0.020 n=600
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • tsc-startup - node (v18.15.0, x64)
  • tsserver-startup - node (v18.15.0, x64)
  • tsserverlibrary-startup - node (v18.15.0, x64)
  • typescript-startup - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Angular - node (v18.15.0, x64)
Memory used 295,509k (± 0.01%) 295,550k (± 0.01%) ~ 295,480k 295,608k p=0.093 n=6
Parse Time 2.65s (± 0.00%) 2.65s (± 0.31%) ~ 2.65s 2.67s p=0.405 n=6
Bind Time 0.82s (± 0.50%) 0.83s (± 1.19%) ~ 0.82s 0.84s p=0.056 n=6
Check Time 8.17s (± 0.21%) 8.20s (± 0.23%) +0.04s (+ 0.43%) 8.18s 8.23s p=0.012 n=6
Emit Time 7.10s (± 0.19%) 7.11s (± 0.44%) ~ 7.06s 7.14s p=0.331 n=6
Total Time 18.73s (± 0.15%) 18.79s (± 0.15%) +0.06s (+ 0.30%) 18.75s 18.82s p=0.015 n=6
Compiler-Unions - node (v18.15.0, x64)
Memory used 193,460k (± 1.55%) 192,479k (± 1.23%) ~ 191,476k 197,300k p=0.423 n=6
Parse Time 1.35s (± 0.56%) 1.36s (± 0.55%) ~ 1.35s 1.37s p=0.195 n=6
Bind Time 0.72s (± 0.00%) 0.72s (± 0.00%) ~ 0.72s 0.72s p=1.000 n=6
Check Time 9.35s (± 0.24%) 9.37s (± 0.43%) ~ 9.32s 9.42s p=0.560 n=6
Emit Time 2.63s (± 0.78%) 2.63s (± 0.54%) ~ 2.61s 2.65s p=1.000 n=6
Total Time 14.06s (± 0.17%) 14.07s (± 0.24%) ~ 14.03s 14.11s p=0.571 n=6
Monaco - node (v18.15.0, x64)
Memory used 347,430k (± 0.01%) 347,433k (± 0.00%) ~ 347,419k 347,453k p=0.521 n=6
Parse Time 2.46s (± 0.55%) 2.46s (± 0.55%) ~ 2.44s 2.48s p=0.934 n=6
Bind Time 0.92s (± 0.59%) 0.93s (± 0.44%) ~ 0.92s 0.93s p=0.282 n=6
Check Time 6.91s (± 0.37%) 6.94s (± 0.40%) ~ 6.91s 6.98s p=0.142 n=6
Emit Time 4.04s (± 0.37%) 4.04s (± 0.40%) ~ 4.02s 4.07s p=0.802 n=6
Total Time 14.34s (± 0.19%) 14.37s (± 0.32%) ~ 14.32s 14.44s p=0.258 n=6
TFS - node (v18.15.0, x64)
Memory used 302,754k (± 0.00%) 302,769k (± 0.00%) +15k (+ 0.00%) 302,762k 302,777k p=0.020 n=6
Parse Time 2.01s (± 1.03%) 1.99s (± 1.84%) ~ 1.95s 2.04s p=0.573 n=6
Bind Time 1.00s (± 1.67%) 1.00s (± 0.52%) ~ 0.99s 1.00s p=0.325 n=6
Check Time 6.29s (± 0.34%) 6.34s (± 0.29%) +0.05s (+ 0.74%) 6.31s 6.36s p=0.012 n=6
Emit Time 3.57s (± 0.64%) 3.59s (± 0.52%) ~ 3.57s 3.62s p=0.326 n=6
Total Time 12.87s (± 0.24%) 12.91s (± 0.46%) ~ 12.86s 13.02s p=0.226 n=6
material-ui - node (v18.15.0, x64)
Memory used 506,806k (± 0.00%) 506,822k (± 0.01%) ~ 506,783k 506,872k p=0.575 n=6
Parse Time 2.59s (± 0.65%) 2.59s (± 0.60%) ~ 2.57s 2.61s p=1.000 n=6
Bind Time 1.00s (± 1.09%) 1.00s (± 0.84%) ~ 0.98s 1.00s p=0.282 n=6
Check Time 16.98s (± 0.37%) 17.01s (± 0.70%) ~ 16.85s 17.16s p=0.689 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 20.57s (± 0.42%) 20.60s (± 0.58%) ~ 20.42s 20.73s p=0.630 n=6
xstate - node (v18.15.0, x64)
Memory used 512,956k (± 0.01%) 512,978k (± 0.01%) ~ 512,919k 513,025k p=0.689 n=6
Parse Time 3.28s (± 0.41%) 3.28s (± 0.31%) ~ 3.27s 3.29s p=0.929 n=6
Bind Time 1.53s (± 0.27%) 1.54s (± 0.49%) +0.01s (+ 0.65%) 1.53s 1.55s p=0.024 n=6
Check Time 2.84s (± 0.62%) 2.85s (± 0.53%) ~ 2.84s 2.88s p=0.124 n=6
Emit Time 0.07s (± 0.00%) 0.07s (± 0.00%) ~ 0.07s 0.07s p=1.000 n=6
Total Time 7.72s (± 0.14%) 7.74s (± 0.20%) ~ 7.72s 7.75s p=0.139 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Angular - node (v18.15.0, x64)
  • Compiler-Unions - node (v18.15.0, x64)
  • Monaco - node (v18.15.0, x64)
  • TFS - node (v18.15.0, x64)
  • material-ui - node (v18.15.0, x64)
  • xstate - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

tsserver

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-UnionsTSServer - node (v18.15.0, x64)
Req 1 - updateOpen 2,341ms (± 0.79%) 2,353ms (± 0.79%) ~ 2,323ms 2,367ms p=0.128 n=6
Req 2 - geterr 5,445ms (± 1.36%) 5,511ms (± 1.49%) ~ 5,404ms 5,594ms p=0.128 n=6
Req 3 - references 324ms (± 0.87%) 324ms (± 0.28%) ~ 323ms 325ms p=0.157 n=6
Req 4 - navto 275ms (± 1.38%) 272ms (± 0.61%) ~ 270ms 274ms p=0.370 n=6
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) ~ 1,356 1,356 p=1.000 n=6
Req 5 - completionInfo 88ms (± 5.61%) 88ms (± 8.18%) ~ 79ms 93ms p=1.000 n=6
CompilerTSServer - node (v18.15.0, x64)
Req 1 - updateOpen 2,493ms (± 0.54%) 2,488ms (± 1.14%) ~ 2,443ms 2,516ms p=0.936 n=6
Req 2 - geterr 4,113ms (± 1.38%) 4,160ms (± 2.16%) ~ 4,060ms 4,249ms p=0.378 n=6
Req 3 - references 339ms (± 1.50%) 335ms (± 1.29%) ~ 332ms 343ms p=0.255 n=6
Req 4 - navto 284ms (± 0.43%) 284ms (± 0.29%) ~ 283ms 285ms p=0.787 n=6
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) ~ 1,518 1,518 p=1.000 n=6
Req 5 - completionInfo 87ms (± 7.37%) 82ms (± 7.74%) ~ 74ms 90ms p=0.157 n=6
xstateTSServer - node (v18.15.0, x64)
Req 1 - updateOpen 2,606ms (± 0.67%) 2,606ms (± 1.00%) ~ 2,575ms 2,639ms p=0.873 n=6
Req 2 - geterr 1,719ms (± 2.57%) 1,754ms (± 2.40%) ~ 1,686ms 1,785ms p=0.128 n=6
Req 3 - references 112ms (± 9.07%) 115ms (± 9.32%) ~ 101ms 124ms p=0.936 n=6
Req 4 - navto 368ms (± 1.26%) 366ms (± 0.22%) ~ 365ms 367ms p=0.933 n=6
Req 5 - completionInfo count 2,073 (± 0.00%) 2,073 (± 0.00%) ~ 2,073 2,073 p=1.000 n=6
Req 5 - completionInfo 311ms (± 1.64%) 309ms (± 2.47%) ~ 296ms 316ms p=1.000 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • CompilerTSServer - node (v18.15.0, x64)
  • Compiler-UnionsTSServer - node (v18.15.0, x64)
  • xstateTSServer - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@gabritto
Copy link
Member

gabritto commented Jan 9, 2024

@typescript-bot perf test this
@typescript-bot perf test this public

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 9, 2024

Heya @gabritto, I've started to run the public perf test suite on this PR at 608f7c3. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 9, 2024

Heya @gabritto, I've started to run the regular perf test suite on this PR at 608f7c3. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

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

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
self-build-src - node (v20.5.1, x64)
Memory used 2,706,637k (± 7.10%) 2,657,320k (± 5.37%) ~ 2,573,854k 2,923,259k p=0.298 n=6
Parse Time 5.03s (± 1.03%) 5.04s (± 0.35%) ~ 5.01s 5.05s p=1.000 n=6
Bind Time 1.99s (± 0.89%) 1.99s (± 0.74%) ~ 1.97s 2.01s p=0.512 n=6
Check Time 31.94s (± 0.22%) 32.13s (± 0.43%) +0.18s (+ 0.57%) 31.93s 32.32s p=0.037 n=6
Emit Time 2.83s (± 5.12%) 2.85s (± 2.49%) ~ 2.76s 2.92s p=0.810 n=6
Total Time 41.81s (± 0.53%) 42.01s (± 0.23%) ~ 41.89s 42.17s p=0.078 n=6
self-compiler - node (v20.5.1, x64)
Memory used 418,897k (± 0.02%) 418,952k (± 0.03%) ~ 418,845k 419,133k p=0.230 n=6
Parse Time 2.89s (± 0.52%) 2.88s (± 0.74%) ~ 2.84s 2.90s p=0.324 n=6
Bind Time 1.13s (± 0.48%) 1.14s (± 0.72%) ~ 1.13s 1.15s p=0.859 n=6
Check Time 14.08s (± 0.29%) 14.05s (± 0.18%) ~ 14.01s 14.07s p=0.412 n=6
Emit Time 1.05s (± 1.20%) 1.05s (± 1.40%) ~ 1.03s 1.07s p=0.867 n=6
Total Time 19.16s (± 0.14%) 19.12s (± 0.24%) ~ 19.05s 19.18s p=0.075 n=6
vscode - node (v20.5.1, x64)
Memory used 2,828,080k (± 0.00%) 2,828,049k (± 0.00%) ~ 2,828,021k 2,828,082k p=0.173 n=6
Parse Time 10.72s (± 0.20%) 10.72s (± 0.29%) ~ 10.68s 10.77s p=0.871 n=6
Bind Time 3.42s (± 0.49%) 3.43s (± 0.29%) ~ 3.41s 3.44s p=0.391 n=6
Check Time 56.26s (± 0.40%) 56.28s (± 0.23%) ~ 56.14s 56.43s p=0.873 n=6
Emit Time 16.28s (± 0.64%) 16.19s (± 1.22%) ~ 15.93s 16.50s p=0.471 n=6
Total Time 86.68s (± 0.37%) 86.62s (± 0.28%) ~ 86.36s 87.07s p=0.936 n=6
System info unknown
Hosts
  • node (v20.5.1, x64)
Scenarios
  • self-build-src - node (v20.5.1, x64)
  • self-compiler - node (v20.5.1, x64)
  • vscode - node (v20.5.1, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

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

Here they are:

startup

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
tsc-startup - node (v18.15.0, x64)
Execution time 154.40ms (± 0.21%) 154.33ms (± 0.18%) ~ 153.29ms 156.35ms p=0.101 n=600
tsserver-startup - node (v18.15.0, x64)
Execution time 230.13ms (± 0.14%) 230.07ms (± 0.16%) -0.06ms (- 0.03%) 228.62ms 233.07ms p=0.002 n=600
tsserverlibrary-startup - node (v18.15.0, x64)
Execution time 231.61ms (± 0.18%) 231.65ms (± 0.19%) ~ 229.85ms 238.54ms p=0.222 n=600
typescript-startup - node (v18.15.0, x64)
Execution time 230.89ms (± 0.19%) 231.01ms (± 0.19%) +0.12ms (+ 0.05%) 229.25ms 236.76ms p=0.010 n=600
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • tsc-startup - node (v18.15.0, x64)
  • tsserver-startup - node (v18.15.0, x64)
  • tsserverlibrary-startup - node (v18.15.0, x64)
  • typescript-startup - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Angular - node (v18.15.0, x64)
Memory used 295,509k (± 0.01%) 295,533k (± 0.01%) ~ 295,484k 295,569k p=0.090 n=6
Parse Time 2.65s (± 0.19%) 2.65s (± 0.50%) ~ 2.64s 2.67s p=0.794 n=6
Bind Time 0.82s (± 1.54%) 0.82s (± 0.00%) ~ 0.82s 0.82s p=1.000 n=6
Check Time 8.15s (± 0.30%) 8.19s (± 0.20%) +0.04s (+ 0.53%) 8.17s 8.21s p=0.012 n=6
Emit Time 7.10s (± 0.29%) 7.10s (± 0.40%) ~ 7.08s 7.14s p=0.682 n=6
Total Time 18.72s (± 0.19%) 18.76s (± 0.18%) ~ 18.72s 18.82s p=0.077 n=6
Compiler-Unions - node (v18.15.0, x64)
Memory used 192,519k (± 1.29%) 191,962k (± 0.55%) ~ 191,492k 194,112k p=0.378 n=6
Parse Time 1.35s (± 0.60%) 1.35s (± 0.30%) ~ 1.35s 1.36s p=0.584 n=6
Bind Time 0.72s (± 0.00%) 0.72s (± 0.00%) ~ 0.72s 0.72s p=1.000 n=6
Check Time 9.35s (± 0.45%) 9.35s (± 0.29%) ~ 9.32s 9.39s p=0.744 n=6
Emit Time 2.63s (± 1.65%) 2.63s (± 0.39%) ~ 2.62s 2.65s p=0.677 n=6
Total Time 14.05s (± 0.45%) 14.06s (± 0.16%) ~ 14.03s 14.09s p=0.809 n=6
Monaco - node (v18.15.0, x64)
Memory used 347,412k (± 0.01%) 347,432k (± 0.00%) ~ 347,411k 347,444k p=0.066 n=6
Parse Time 2.46s (± 0.31%) 2.46s (± 0.21%) ~ 2.46s 2.47s p=0.784 n=6
Bind Time 0.93s (± 0.81%) 0.93s (± 0.56%) ~ 0.92s 0.93s p=0.784 n=6
Check Time 6.90s (± 0.50%) 6.92s (± 0.08%) ~ 6.91s 6.92s p=0.869 n=6
Emit Time 4.05s (± 0.26%) 4.05s (± 0.29%) ~ 4.04s 4.07s p=0.619 n=6
Total Time 14.34s (± 0.24%) 14.36s (± 0.14%) ~ 14.33s 14.39s p=0.373 n=6
TFS - node (v18.15.0, x64)
Memory used 302,768k (± 0.01%) 302,772k (± 0.00%) ~ 302,759k 302,797k p=0.423 n=6
Parse Time 2.01s (± 0.96%) 2.00s (± 0.97%) ~ 1.98s 2.03s p=0.289 n=6
Bind Time 1.01s (± 1.66%) 1.00s (± 1.09%) ~ 0.99s 1.02s p=0.247 n=6
Check Time 6.30s (± 0.34%) 6.34s (± 0.37%) ~ 6.30s 6.36s p=0.063 n=6
Emit Time 3.57s (± 0.29%) 3.57s (± 0.46%) ~ 3.54s 3.58s p=0.869 n=6
Total Time 12.90s (± 0.20%) 12.90s (± 0.28%) ~ 12.86s 12.96s p=1.000 n=6
material-ui - node (v18.15.0, x64)
Memory used 508,275k (± 0.00%) 508,256k (± 0.00%) ~ 508,222k 508,280k p=0.261 n=6
Parse Time 2.58s (± 0.45%) 2.59s (± 0.62%) ~ 2.57s 2.61s p=0.316 n=6
Bind Time 1.00s (± 0.84%) 0.99s (± 0.99%) ~ 0.98s 1.00s p=0.256 n=6
Check Time 17.05s (± 0.38%) 17.05s (± 0.32%) ~ 16.96s 17.13s p=0.936 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 20.63s (± 0.34%) 20.63s (± 0.24%) ~ 20.57s 20.72s p=0.936 n=6
xstate - node (v18.15.0, x64)
Memory used 512,929k (± 0.02%) 512,955k (± 0.02%) ~ 512,795k 513,099k p=0.575 n=6
Parse Time 3.27s (± 0.16%) 3.28s (± 0.16%) ~ 3.27s 3.28s p=0.311 n=6
Bind Time 1.54s (± 0.34%) 1.53s (± 0.27%) ~ 1.53s 1.54s p=0.112 n=6
Check Time 2.85s (± 1.24%) 2.86s (± 0.36%) ~ 2.85s 2.87s p=0.200 n=6
Emit Time 0.07s (± 5.69%) 0.07s (± 5.69%) ~ 0.07s 0.08s p=1.000 n=6
Total Time 7.73s (± 0.56%) 7.74s (± 0.19%) ~ 7.72s 7.76s p=0.195 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Angular - node (v18.15.0, x64)
  • Compiler-Unions - node (v18.15.0, x64)
  • Monaco - node (v18.15.0, x64)
  • TFS - node (v18.15.0, x64)
  • material-ui - node (v18.15.0, x64)
  • xstate - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

tsserver

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-UnionsTSServer - node (v18.15.0, x64)
Req 1 - updateOpen 2,346ms (± 0.40%) 2,350ms (± 0.81%) ~ 2,333ms 2,375ms p=0.810 n=6
Req 2 - geterr 5,425ms (± 1.25%) 5,463ms (± 1.04%) ~ 5,399ms 5,536ms p=0.149 n=6
Req 3 - references 324ms (± 1.02%) 323ms (± 0.82%) ~ 321ms 328ms p=0.517 n=6
Req 4 - navto 277ms (± 1.02%) 275ms (± 1.28%) ~ 270ms 278ms p=0.391 n=6
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) ~ 1,356 1,356 p=1.000 n=6
Req 5 - completionInfo 83ms (± 6.42%) 86ms (± 6.60%) ~ 78ms 93ms p=0.505 n=6
CompilerTSServer - node (v18.15.0, x64)
Req 1 - updateOpen 2,469ms (± 1.24%) 2,482ms (± 1.25%) ~ 2,427ms 2,509ms p=0.378 n=6
Req 2 - geterr 4,137ms (± 1.61%) 4,119ms (± 1.38%) ~ 4,081ms 4,231ms p=0.810 n=6
Req 3 - references 332ms (± 0.52%) 335ms (± 1.31%) ~ 332ms 341ms p=0.162 n=6
Req 4 - navto 286ms (± 1.05%) 286ms (± 1.03%) ~ 283ms 291ms p=0.805 n=6
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) ~ 1,518 1,518 p=1.000 n=6
Req 5 - completionInfo 77ms (± 7.56%) 84ms (± 8.47%) ~ 73ms 90ms p=0.145 n=6
xstateTSServer - node (v18.15.0, x64)
Req 1 - updateOpen 2,608ms (± 0.45%) 2,602ms (± 0.68%) ~ 2,577ms 2,618ms p=0.748 n=6
Req 2 - geterr 1,741ms (± 1.12%) 1,741ms (± 2.15%) ~ 1,693ms 1,778ms p=0.936 n=6
Req 3 - references 113ms (± 8.96%) 123ms (± 7.19%) ~ 105ms 128ms p=0.086 n=6
Req 4 - navto 365ms (± 0.21%) 365ms (± 0.71%) ~ 360ms 368ms p=1.000 n=6
Req 5 - completionInfo count 2,073 (± 0.00%) 2,073 (± 0.00%) ~ 2,073 2,073 p=1.000 n=6
Req 5 - completionInfo 310ms (± 2.22%) 310ms (± 1.62%) ~ 304ms 315ms p=0.748 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • CompilerTSServer - node (v18.15.0, x64)
  • Compiler-UnionsTSServer - node (v18.15.0, x64)
  • xstateTSServer - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@gabritto
Copy link
Member

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 10, 2024

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 10, 2024

Hey @gabritto, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/159393/artifacts?artifactName=tgz&fileId=19921885F805986E3E562436471750DCDA54E2AC6F20EC1C37EF14DD5FCBA23602&fileName=/typescript-5.4.0-insiders.20240110.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/[email protected]".;

@jakebailey jakebailey requested a review from gabritto April 19, 2024 18:54
@jakebailey
Copy link
Member

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 19, 2024

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
test top400 ✅ Started ✅ Results
user test this ✅ Started ✅ Results
run dt ✅ Started ✅ Results
perf test this faster ✅ Started 👀 Results

@typescript-bot
Copy link
Collaborator

Hey @jakebailey, the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the user tests comparing main and refs/pull/49218/merge:

Everything looks good!

@typescript-bot
Copy link
Collaborator

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

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Angular - node (v18.15.0, x64)
Memory used 297,135k (± 0.00%) 297,146k (± 0.00%) ~ 297,133k 297,159k p=0.093 n=6
Parse Time 3.26s (± 0.46%) 3.26s (± 0.61%) ~ 3.22s 3.28s p=0.805 n=6
Bind Time 0.97s (± 0.56%) 0.98s (± 0.53%) ~ 0.97s 0.98s p=0.640 n=6
Check Time 9.84s (± 0.45%) 9.86s (± 0.44%) ~ 9.83s 9.93s p=0.254 n=6
Emit Time 8.45s (± 0.36%) 8.46s (± 0.29%) ~ 8.43s 8.49s p=0.686 n=6
Total Time 22.51s (± 0.29%) 22.55s (± 0.21%) ~ 22.49s 22.61s p=0.196 n=6
Compiler-Unions - node (v18.15.0, x64)
Memory used 192,383k (± 0.77%) 192,426k (± 0.76%) ~ 191,790k 195,420k p=0.230 n=6
Parse Time 1.64s (± 1.12%) 1.63s (± 1.82%) ~ 1.59s 1.68s p=0.566 n=6
Bind Time 0.87s (± 0.63%) 0.87s (± 1.88%) ~ 0.85s 0.89s p=1.000 n=6
Check Time 11.31s (± 0.38%) 11.35s (± 0.32%) ~ 11.28s 11.38s p=0.090 n=6
Emit Time 3.14s (± 0.77%) 3.14s (± 0.91%) ~ 3.10s 3.18s p=0.935 n=6
Total Time 16.96s (± 0.32%) 16.99s (± 0.16%) ~ 16.95s 17.02s p=0.295 n=6
mui-docs - node (v18.15.0, x64)
Memory used 1,752,886k (± 0.00%) 1,752,888k (± 0.00%) ~ 1,752,826k 1,752,925k p=0.689 n=6
Parse Time 6.84s (± 0.26%) 6.85s (± 0.49%) ~ 6.81s 6.88s p=0.677 n=6
Bind Time 2.29s (± 1.17%) 2.29s (± 0.45%) ~ 2.28s 2.31s p=0.357 n=6
Check Time 57.02s (± 0.64%) 56.85s (± 0.54%) ~ 56.34s 57.16s p=0.936 n=6
Emit Time 0.14s (± 2.95%) 0.14s (± 2.95%) ~ 0.13s 0.14s p=1.000 n=6
Total Time 66.28s (± 0.52%) 66.13s (± 0.41%) ~ 65.66s 66.39s p=0.936 n=6
self-build-src - node (v18.15.0, x64)
Memory used 2,307,703k (± 0.04%) 2,308,397k (± 0.03%) ~ 2,307,583k 2,309,015k p=0.173 n=6
Parse Time 7.36s (± 0.69%) 7.42s (± 0.64%) ~ 7.37s 7.47s p=0.090 n=6
Bind Time 2.75s (± 0.99%) 2.73s (± 0.91%) ~ 2.70s 2.76s p=0.295 n=6
Check Time 49.32s (± 0.70%) 49.46s (± 0.80%) ~ 49.09s 50.01s p=0.689 n=6
Emit Time 3.95s (± 1.75%) 4.09s (± 2.65%) +0.14s (+ 3.55%) 3.98s 4.26s p=0.037 n=6
Total Time 63.38s (± 0.63%) 63.70s (± 0.49%) ~ 63.36s 64.17s p=0.173 n=6
self-build-src-public-api - node (v18.15.0, x64)
Memory used 2,382,629k (± 0.03%) 2,382,909k (± 0.02%) ~ 2,382,434k 2,384,034k p=0.298 n=6
Parse Time 6.20s (± 0.80%) 6.25s (± 0.80%) ~ 6.16s 6.30s p=0.065 n=6
Bind Time 2.07s (± 3.61%) 2.08s (± 4.11%) ~ 2.01s 2.25s p=0.574 n=6
Check Time 40.23s (± 0.70%) 40.32s (± 0.40%) ~ 40.03s 40.48s p=0.470 n=6
Emit Time 3.20s (± 2.00%) 3.21s (± 2.37%) ~ 3.09s 3.29s p=1.000 n=6
Total Time 51.71s (± 0.39%) 51.88s (± 0.21%) ~ 51.75s 52.03s p=0.173 n=6
self-compiler - node (v18.15.0, x64)
Memory used 419,238k (± 0.01%) 419,274k (± 0.00%) ~ 419,257k 419,279k p=0.065 n=6
Parse Time 4.20s (± 0.44%) 4.20s (± 0.42%) ~ 4.17s 4.22s p=1.000 n=6
Bind Time 1.55s (± 1.49%) 1.59s (± 1.95%) +0.04s (+ 2.47%) 1.56s 1.63s p=0.041 n=6
Check Time 22.25s (± 0.31%) 22.27s (± 0.32%) ~ 22.19s 22.37s p=0.747 n=6
Emit Time 1.71s (± 2.08%) 1.71s (± 0.81%) ~ 1.69s 1.72s p=0.746 n=6
Total Time 29.70s (± 0.28%) 29.76s (± 0.19%) ~ 29.67s 29.84s p=0.228 n=6
ts-pre-modules - node (v18.15.0, x64)
Memory used 368,965k (± 0.01%) 369,101k (± 0.05%) ~ 368,975k 369,429k p=0.093 n=6
Parse Time 3.66s (± 0.76%) 3.65s (± 0.32%) ~ 3.64s 3.67s p=0.517 n=6
Bind Time 1.92s (± 0.64%) 1.92s (± 1.23%) ~ 1.88s 1.95s p=1.000 n=6
Check Time 19.45s (± 0.35%) 19.44s (± 0.35%) ~ 19.33s 19.52s p=1.000 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 25.04s (± 0.36%) 25.01s (± 0.35%) ~ 24.85s 25.11s p=0.810 n=6
vscode - node (v18.15.0, x64)
Memory used 2,919,625k (± 0.01%) 2,919,700k (± 0.01%) ~ 2,919,510k 2,919,882k p=0.936 n=6
Parse Time 16.54s (± 0.47%) 16.55s (± 0.35%) ~ 16.47s 16.65s p=0.872 n=6
Bind Time 4.96s (± 0.38%) 4.95s (± 0.45%) ~ 4.93s 4.98s p=0.195 n=6
Check Time 88.85s (± 2.06%) 88.17s (± 0.62%) ~ 87.59s 89.07s p=0.689 n=6
Emit Time 24.66s (± 6.22%) 25.20s (± 8.45%) ~ 23.71s 28.02s p=0.936 n=6
Total Time 135.01s (± 1.63%) 134.87s (± 1.45%) ~ 132.92s 137.34s p=0.936 n=6
webpack - node (v18.15.0, x64)
Memory used 409,547k (± 0.01%) 409,508k (± 0.00%) ~ 409,481k 409,535k p=0.230 n=6
Parse Time 3.92s (± 0.77%) 3.94s (± 0.72%) ~ 3.91s 3.99s p=0.418 n=6
Bind Time 1.64s (± 0.90%) 1.64s (± 0.54%) ~ 1.63s 1.65s p=0.804 n=6
Check Time 16.92s (± 0.34%) 16.92s (± 0.33%) ~ 16.86s 17.00s p=1.000 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 22.49s (± 0.17%) 22.50s (± 0.21%) ~ 22.43s 22.56s p=0.747 n=6
xstate-main - node (v18.15.0, x64)
Memory used 459,110k (± 0.01%) 459,206k (± 0.02%) ~ 459,116k 459,321k p=0.054 n=6
Parse Time 3.99s (± 0.61%) 4.00s (± 0.65%) ~ 3.97s 4.03s p=0.223 n=6
Bind Time 1.48s (± 0.92%) 1.47s (± 0.70%) ~ 1.45s 1.48s p=0.241 n=6
Check Time 22.27s (± 0.85%) 22.51s (± 0.37%) +0.24s (+ 1.09%) 22.35s 22.58s p=0.020 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 27.73s (± 0.60%) 27.99s (± 0.36%) +0.25s (+ 0.91%) 27.79s 28.07s p=0.020 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Angular - node (v18.15.0, x64)
  • Compiler-Unions - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-build-src-public-api - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • ts-pre-modules - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate-main - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

Comment on lines +20773 to +20774
const elementTypes: Type[] = [];
const elementFlags: ElementFlags[] = [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically we use append rather than pushing onto an empty list directly; this is typically more efficient due to how the runtime constructs arrays.

Comment on lines +24506 to +24507
!!(tupleStructureComparisonKind & TupleStructureComparisonKind.MatchFixed && f1 & ElementFlags.Fixed && f2 & ElementFlags.Fixed) ||
!!(tupleStructureComparisonKind & TupleStructureComparisonKind.MatchVariable && f1 & ElementFlags.Variable && f2 & ElementFlags.Variable);
Copy link
Member

@jakebailey jakebailey Apr 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why aren't these something like (f1 & ElementFlags.Fixed) === (f2 & ElementFlags.Fixed), as the original code did?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I guess that breaks things.

@@ -24440,9 +24498,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
return undefined;
}

function isTupleTypeStructureMatching(t1: TupleTypeReference, t2: TupleTypeReference) {
function isTupleTypeStructureMatching(t1: TupleTypeReference, t2: TupleTypeReference, tupleStructureComparisonKind: TupleStructureComparisonKind) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious if we could just accept ElementFlags as a mask here instead of coming up with a new enum.

@gabritto
Copy link
Member

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 19, 2024

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
pack this ✅ Started ✅ Results

Copy link
Member

@gabritto gabritto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I did review this a second time earlier this year, and I left a comment with a case that I think might be wrong with this PR, but forgot to "request changes": #49218 (comment)

Sorry about that.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 19, 2024

Hey @gabritto, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/161366/artifacts?artifactName=tgz&fileId=BB7F0897DE0CAA4B165664B27871DEFB6340EBB3BED5D0A21E1AB7AAB0E1143E02&fileName=/typescript-5.5.0-insiders.20240419.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/[email protected]".;

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the top 400 repos comparing main and refs/pull/49218/merge:

Everything looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Status: Waiting on author
6 participants