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

Add fallback logic for generating signatures for unions of array members #53489

Merged
merged 1 commit into from
May 16, 2023

Conversation

weswigham
Copy link
Member

Fixes #44373

With this PR, when we see a type like (A[] | B[])["member"] and look for signatures on it, and find none, we reconstruct (A | B)[]["member"] and instead look up signatures on that. This only applies to array and tuple types because, well, arrays are special. We treat them as covariant when they're not, and we know their collection-like behavior is consistent. This logic does not apply to any custom subtypes of arrays or array-similar things, like UInt8Array - those may have less or more type parameters that both make the reconstruction difficult and potentially break our expectations on how collection-element-like the type parameters are.

This allows things like this:

// @target: es6
interface Fizz {
    id: number;
    fizz: string;
}

interface Buzz {
    id: number;
    buzz: string;
}

([] as Fizz[] | Buzz[]).filter(item => item.id < 5);
([] as Fizz[] | readonly Buzz[]).filter(item => item.id < 5); 

([] as Fizz[] | Buzz[]).find(item => item);
declare function isFizz(x: unknown): x is Fizz;
([] as Fizz[] | Buzz[]).find(isFizz);
declare function isBuzz(x: unknown): x is Buzz;
([] as Fizz[] | Buzz[]).find(isBuzz);

([] as Fizz[] | Buzz[]).every(item => item.id < 5);

([] as Fizz[] | Buzz[]).reduce(item => item);

([] as [Fizz] | readonly [Buzz?]).filter(item => item?.id < 5);

to all work mostly like you'd expect (with maybe the caveat that output arrays are unions of elements within a single array rather than unions of array types).

I'd say that it's possible to broaden this logic to other types using variance measurement logic and some hearty assumptions about how types behave based on their variance, but I feel much better about it making this an array-only change, at least right now.

@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Mar 24, 2023
@weswigham
Copy link
Member Author

@typescript-bot test this
@typescript-bot run dt
@typescript-bot test top100
@typescript-bot perf test this
@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 24, 2023

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 24, 2023

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 24, 2023

Heya @weswigham, I've started to run the diff-based top-repos suite on this PR at 975ba5d. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 24, 2023

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 24, 2023

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 24, 2023

Hey @weswigham, 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/150967/artifacts?artifactName=tgz&fileId=4F4F2D50012610DBE83CB94154D5058BACD4A956BBC583BEB5D9E7D7A6B98AC402&fileName=/typescript-5.1.0-insiders.20230324.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

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

Here they are:

Compiler

Comparison Report - main..53489
Metric main 53489 Delta Best Worst p-value
Angular - node (v18.10.0, x64)
Memory used 362,093k (± 0.01%) 362,102k (± 0.01%) ~ 362,064k 362,128k p=0.575 n=6
Parse Time 3.40s (± 0.29%) 3.38s (± 0.49%) -0.02s (- 0.64%) 3.35s 3.40s p=0.022 n=6
Bind Time 1.12s (± 0.46%) 1.12s (± 0.00%) ~ 1.12s 1.12s p=0.174 n=6
Check Time 8.72s (± 0.28%) 8.70s (± 0.54%) ~ 8.64s 8.76s p=0.568 n=6
Emit Time 7.54s (± 0.57%) 7.49s (± 0.76%) ~ 7.38s 7.55s p=0.168 n=6
Total Time 20.78s (± 0.28%) 20.69s (± 0.35%) ~ 20.62s 20.81s p=0.064 n=6
Compiler-Unions - node (v18.10.0, x64)
Memory used 193,687k (± 1.63%) 191,777k (± 1.22%) ~ 190,763k 196,565k p=0.575 n=6
Parse Time 1.50s (± 0.60%) 1.49s (± 0.78%) ~ 1.48s 1.51s p=0.214 n=6
Bind Time 0.77s (± 0.97%) 0.77s (± 0.67%) ~ 0.76s 0.77s p=0.241 n=6
Check Time 9.66s (± 0.53%) 9.71s (± 0.76%) ~ 9.60s 9.78s p=0.334 n=6
Emit Time 2.73s (± 0.89%) 2.71s (± 0.28%) ~ 2.70s 2.72s p=0.331 n=6
Total Time 14.66s (± 0.53%) 14.68s (± 0.57%) ~ 14.57s 14.78s p=0.748 n=6
Monaco - node (v18.10.0, x64)
Memory used 346,449k (± 0.01%) 346,442k (± 0.01%) ~ 346,363k 346,502k p=1.000 n=6
Parse Time 2.60s (± 0.45%) 2.60s (± 1.01%) ~ 2.56s 2.63s p=0.513 n=6
Bind Time 1.00s (± 0.51%) 1.01s (± 1.03%) ~ 1.00s 1.03s p=0.051 n=6
Check Time 7.14s (± 0.44%) 7.11s (± 0.39%) ~ 7.07s 7.14s p=0.418 n=6
Emit Time 4.25s (± 0.59%) 4.26s (± 0.38%) ~ 4.23s 4.28s p=0.870 n=6
Total Time 14.99s (± 0.35%) 14.98s (± 0.13%) ~ 14.96s 15.01s p=0.627 n=6
TFS - node (v18.10.0, x64)
Memory used 300,672k (± 0.01%) 300,691k (± 0.01%) ~ 300,675k 300,728k p=0.230 n=6
Parse Time 2.08s (± 0.77%) 2.06s (± 1.43%) ~ 2.01s 2.09s p=0.323 n=6
Bind Time 1.14s (± 0.55%) 1.14s (± 0.66%) ~ 1.13s 1.15s p=0.718 n=6
Check Time 6.55s (± 0.48%) 6.54s (± 0.69%) ~ 6.47s 6.59s p=1.000 n=6
Emit Time 3.86s (± 0.35%) 3.84s (± 0.97%) ~ 3.80s 3.89s p=0.293 n=6
Total Time 13.63s (± 0.34%) 13.58s (± 0.74%) ~ 13.41s 13.71s p=0.371 n=6
material-ui - node (v18.10.0, x64)
Memory used 477,137k (± 0.01%) 477,122k (± 0.01%) ~ 477,096k 477,167k p=0.521 n=6
Parse Time 3.01s (± 2.10%) 2.99s (± 2.79%) ~ 2.91s 3.11s p=0.575 n=6
Bind Time 1.02s (± 7.50%) 0.99s (± 8.85%) ~ 0.91s 1.08s p=0.685 n=6
Check Time 17.45s (± 1.04%) 17.13s (± 0.45%) -0.32s (- 1.82%) 17.06s 17.27s p=0.008 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 21.48s (± 0.89%) 21.12s (± 0.45%) -0.36s (- 1.68%) 20.99s 21.27s p=0.008 n=6
xstate - node (v18.10.0, x64)
Memory used 552,893k (± 0.02%) 552,929k (± 0.02%) ~ 552,827k 553,060k p=0.521 n=6
Parse Time 3.80s (± 0.59%) 3.79s (± 0.80%) ~ 3.75s 3.82s p=0.331 n=6
Bind Time 1.71s (± 0.68%) 1.70s (± 0.61%) ~ 1.69s 1.72s p=0.241 n=6
Check Time 2.87s (± 0.92%) 2.86s (± 0.41%) ~ 2.84s 2.87s p=0.936 n=6
Emit Time 0.08s (± 0.00%) 0.08s (± 0.00%) ~ 0.08s 0.08s p=1.000 n=6
Total Time 8.47s (± 0.60%) 8.43s (± 0.43%) ~ 8.38s 8.47s p=0.296 n=6
Angular - node (v16.17.1, x64)
Memory used 361,441k (± 0.01%) 361,452k (± 0.01%) ~ 361,428k 361,503k p=0.521 n=6
Parse Time 3.52s (± 0.47%) 3.53s (± 0.87%) ~ 3.51s 3.59s p=0.933 n=6
Bind Time 1.19s (± 0.69%) 1.19s (± 0.63%) ~ 1.18s 1.20s p=0.729 n=6
Check Time 9.55s (± 0.55%) 9.52s (± 0.53%) ~ 9.46s 9.58s p=0.296 n=6
Emit Time 7.96s (± 0.99%) 7.93s (± 0.34%) ~ 7.89s 7.96s p=0.686 n=6
Total Time 22.22s (± 0.60%) 22.16s (± 0.20%) ~ 22.09s 22.22s p=0.810 n=6
Compiler-Unions - node (v16.17.1, x64)
Memory used 193,061k (± 0.72%) 192,525k (± 0.02%) ~ 192,486k 192,573k p=0.298 n=6
Parse Time 1.58s (± 1.26%) 1.59s (± 0.66%) ~ 1.58s 1.61s p=0.217 n=6
Bind Time 0.82s (± 0.50%) 0.82s (± 0.50%) ~ 0.82s 0.83s p=1.000 n=6
Check Time 10.37s (± 0.65%) 10.34s (± 0.34%) ~ 10.30s 10.40s p=0.295 n=6
Emit Time 3.00s (± 0.86%) 2.99s (± 0.65%) ~ 2.97s 3.02s p=0.414 n=6
Total Time 15.78s (± 0.58%) 15.76s (± 0.32%) ~ 15.70s 15.83s p=0.520 n=6
Monaco - node (v16.17.1, x64)
Memory used 345,732k (± 0.01%) 345,727k (± 0.01%) ~ 345,707k 345,761k p=0.689 n=6
Parse Time 2.74s (± 1.32%) 2.73s (± 0.54%) ~ 2.72s 2.76s p=0.566 n=6
Bind Time 1.08s (± 1.26%) 1.09s (± 0.58%) ~ 1.08s 1.10s p=0.388 n=6
Check Time 7.82s (± 0.39%) 7.82s (± 0.61%) ~ 7.77s 7.90s p=0.469 n=6
Emit Time 4.48s (± 0.94%) 4.48s (± 1.08%) ~ 4.42s 4.55s p=1.000 n=6
Total Time 16.12s (± 0.54%) 16.11s (± 0.61%) ~ 16.01s 16.27s p=0.688 n=6
TFS - node (v16.17.1, x64)
Memory used 300,022k (± 0.01%) 300,021k (± 0.00%) ~ 300,000k 300,035k p=0.936 n=6
Parse Time 2.19s (± 0.80%) 2.17s (± 0.39%) -0.02s (- 0.99%) 2.16s 2.18s p=0.016 n=6
Bind Time 1.24s (± 1.18%) 1.24s (± 1.19%) ~ 1.22s 1.25s p=0.737 n=6
Check Time 7.22s (± 0.82%) 7.21s (± 0.44%) ~ 7.16s 7.26s p=1.000 n=6
Emit Time 4.32s (± 1.00%) 4.32s (± 0.63%) ~ 4.29s 4.36s p=0.936 n=6
Total Time 14.97s (± 0.64%) 14.93s (± 0.21%) ~ 14.88s 14.97s p=0.336 n=6
material-ui - node (v16.17.1, x64)
Memory used 476,422k (± 0.01%) 476,431k (± 0.01%) ~ 476,389k 476,488k p=0.936 n=6
Parse Time 3.20s (± 1.21%) 3.20s (± 1.14%) ~ 3.13s 3.23s p=0.871 n=6
Bind Time 0.97s (± 2.06%) 0.96s (± 1.02%) ~ 0.95s 0.98s p=0.591 n=6
Check Time 18.14s (± 0.63%) 18.26s (± 0.64%) ~ 18.11s 18.42s p=0.228 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 22.31s (± 0.48%) 22.42s (± 0.61%) ~ 22.25s 22.61s p=0.173 n=6
xstate - node (v16.17.1, x64)
Memory used 550,479k (± 0.01%) 550,541k (± 0.02%) ~ 550,464k 550,797k p=0.748 n=6
Parse Time 3.95s (± 0.49%) 3.94s (± 0.30%) ~ 3.93s 3.96s p=0.226 n=6
Bind Time 1.79s (± 0.82%) 1.79s (± 0.45%) ~ 1.78s 1.80s p=1.000 n=6
Check Time 3.11s (± 0.64%) 3.10s (± 0.41%) ~ 3.08s 3.11s p=0.462 n=6
Emit Time 0.09s (± 4.45%) 0.09s (± 4.45%) ~ 0.09s 0.10s p=1.000 n=6
Total Time 8.94s (± 0.36%) 8.92s (± 0.34%) ~ 8.88s 8.96s p=0.521 n=6
Angular - node (v14.15.1, x64)
Memory used 355,325k (± 0.00%) 355,333k (± 0.00%) ~ 355,323k 355,338k p=0.128 n=6
Parse Time 3.63s (± 0.81%) 3.58s (± 0.23%) -0.04s (- 1.15%) 3.58s 3.60s p=0.011 n=6
Bind Time 1.23s (± 0.89%) 1.23s (± 0.61%) ~ 1.22s 1.24s p=1.000 n=6
Check Time 9.92s (± 0.24%) 9.90s (± 0.36%) ~ 9.83s 9.93s p=0.416 n=6
Emit Time 8.36s (± 0.65%) 8.35s (± 1.06%) ~ 8.27s 8.50s p=0.469 n=6
Total Time 23.13s (± 0.20%) 23.06s (± 0.44%) ~ 22.94s 23.23s p=0.173 n=6
Compiler-Unions - node (v14.15.1, x64)
Memory used 187,755k (± 0.01%) 188,212k (± 0.62%) ~ 187,556k 190,602k p=0.378 n=6
Parse Time 1.61s (± 0.75%) 1.61s (± 0.85%) ~ 1.59s 1.63s p=1.000 n=6
Bind Time 0.85s (± 1.15%) 0.85s (± 0.74%) ~ 0.84s 0.86s p=1.000 n=6
Check Time 10.50s (± 0.73%) 10.52s (± 0.47%) ~ 10.45s 10.60s p=0.871 n=6
Emit Time 3.12s (± 0.43%) 3.20s (± 3.64%) ~ 3.11s 3.42s p=0.221 n=6
Total Time 16.07s (± 0.44%) 16.17s (± 0.72%) ~ 16.03s 16.37s p=0.173 n=6
Monaco - node (v14.15.1, x64)
Memory used 340,596k (± 0.01%) 340,629k (± 0.00%) +33k (+ 0.01%) 340,607k 340,641k p=0.020 n=6
Parse Time 2.84s (± 0.35%) 2.82s (± 0.43%) -0.02s (- 0.88%) 2.80s 2.83s p=0.011 n=6
Bind Time 1.11s (± 0.95%) 1.10s (± 0.37%) ~ 1.09s 1.10s p=0.209 n=6
Check Time 8.17s (± 0.48%) 8.17s (± 0.33%) ~ 8.14s 8.20s p=1.000 n=6
Emit Time 4.68s (± 0.92%) 4.69s (± 0.59%) ~ 4.66s 4.73s p=0.469 n=6
Total Time 16.80s (± 0.36%) 16.78s (± 0.25%) ~ 16.75s 16.86s p=0.293 n=6
TFS - node (v14.15.1, x64)
Memory used 295,093k (± 0.01%) 295,088k (± 0.01%) ~ 295,058k 295,114k p=0.748 n=6
Parse Time 2.40s (± 0.73%) 2.38s (± 0.49%) ~ 2.36s 2.39s p=0.072 n=6
Bind Time 1.06s (± 0.38%) 1.06s (± 0.49%) ~ 1.06s 1.07s p=0.595 n=6
Check Time 7.52s (± 0.72%) 7.50s (± 0.16%) ~ 7.49s 7.52s p=0.327 n=6
Emit Time 4.30s (± 0.80%) 4.28s (± 0.34%) ~ 4.26s 4.30s p=0.259 n=6
Total Time 15.29s (± 0.38%) 15.22s (± 0.20%) ~ 15.17s 15.25s p=0.090 n=6
material-ui - node (v14.15.1, x64)
Memory used 471,990k (± 0.00%) 471,947k (± 0.00%) -43k (- 0.01%) 471,911k 471,969k p=0.013 n=6
Parse Time 3.36s (± 0.51%) 3.35s (± 0.51%) ~ 3.33s 3.38s p=0.411 n=6
Bind Time 1.01s (± 0.51%) 1.00s (± 0.82%) -0.01s (- 0.99%) 0.99s 1.01s p=0.050 n=6
Check Time 19.20s (± 0.61%) 19.10s (± 0.19%) ~ 19.04s 19.13s p=0.065 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 23.57s (± 0.49%) 23.45s (± 0.24%) ~ 23.36s 23.52s p=0.054 n=6
xstate - node (v14.15.1, x64)
Memory used 539,174k (± 0.00%) 539,200k (± 0.00%) ~ 539,171k 539,225k p=0.127 n=6
Parse Time 4.24s (± 0.41%) 4.24s (± 0.82%) ~ 4.20s 4.29s p=0.629 n=6
Bind Time 1.68s (± 0.58%) 1.69s (± 0.90%) ~ 1.67s 1.71s p=0.801 n=6
Check Time 3.22s (± 0.48%) 3.23s (± 0.73%) ~ 3.19s 3.25s p=0.684 n=6
Emit Time 0.09s (± 0.00%) 0.09s (± 0.00%) ~ 0.09s 0.09s p=1.000 n=6
Total Time 9.22s (± 0.14%) 9.24s (± 0.78%) ~ 9.15s 9.32s p=1.000 n=6
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-135-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v18.10.0, x64)
  • node (v16.17.1, x64)
  • node (v14.15.1, x64)
Scenarios
  • Angular - node (v18.10.0, x64)
  • Angular - node (v16.17.1, x64)
  • Angular - node (v14.15.1, x64)
  • Compiler-Unions - node (v18.10.0, x64)
  • Compiler-Unions - node (v16.17.1, x64)
  • Compiler-Unions - node (v14.15.1, x64)
  • Monaco - node (v18.10.0, x64)
  • Monaco - node (v16.17.1, x64)
  • Monaco - node (v14.15.1, x64)
  • TFS - node (v18.10.0, x64)
  • TFS - node (v16.17.1, x64)
  • TFS - node (v14.15.1, x64)
  • material-ui - node (v18.10.0, x64)
  • material-ui - node (v16.17.1, x64)
  • material-ui - node (v14.15.1, x64)
  • xstate - node (v18.10.0, x64)
  • xstate - node (v16.17.1, x64)
  • xstate - node (v14.15.1, x64)
Benchmark Name Iterations
Current 53489 6
Baseline main 6

TSServer

Comparison Report - main..53489
Metric main 53489 Delta Best Worst p-value
Compiler-UnionsTSServer - node (v18.10.0, x64)
Req 1 - updateOpen 2,402ms (± 0.64%) 2,391ms (± 0.52%) ~ 2,372ms 2,411ms p=0.423 n=6
Req 2 - geterr 5,525ms (± 0.37%) 5,545ms (± 0.51%) ~ 5,513ms 5,595ms p=0.298 n=6
Req 3 - references 338ms (± 1.66%) 338ms (± 1.55%) ~ 334ms 348ms p=1.000 n=6
Req 4 - navto 281ms (± 0.35%) 280ms (± 0.60%) ~ 278ms 282ms p=0.318 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 82ms (± 3.53%) 83ms (± 2.73%) ~ 78ms 84ms p=1.000 n=6
CompilerTSServer - node (v18.10.0, x64)
Req 1 - updateOpen 2,534ms (± 1.20%) 2,545ms (± 1.36%) ~ 2,502ms 2,591ms p=0.471 n=6
Req 2 - geterr 4,066ms (± 0.48%) 4,070ms (± 0.56%) ~ 4,042ms 4,103ms p=0.748 n=6
Req 3 - references 349ms (± 1.60%) 352ms (± 0.47%) ~ 350ms 354ms p=0.685 n=6
Req 4 - navto 289ms (± 0.68%) 289ms (± 0.90%) ~ 285ms 293ms p=1.000 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 78ms (± 7.29%) 80ms (± 3.98%) ~ 76ms 86ms p=0.798 n=6
xstateTSServer - node (v18.10.0, x64)
Req 1 - updateOpen 3,026ms (± 0.64%) 3,018ms (± 1.00%) ~ 2,984ms 3,061ms p=0.810 n=6
Req 2 - geterr 1,695ms (± 1.79%) 1,704ms (± 0.79%) ~ 1,680ms 1,719ms p=0.173 n=6
Req 3 - references 107ms (± 0.59%) 107ms (± 1.38%) ~ 104ms 108ms p=0.787 n=6
Req 4 - navto 358ms (± 0.66%) 357ms (± 0.60%) ~ 355ms 360ms p=0.627 n=6
Req 5 - completionInfo count 2,861 (± 0.00%) 2,861 (± 0.00%) ~ 2,861 2,861 p=1.000 n=6
Req 5 - completionInfo 381ms (± 2.07%) 393ms (± 5.30%) ~ 379ms 433ms p=0.261 n=6
Compiler-UnionsTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 2,511ms (± 0.89%) 2,517ms (± 1.26%) ~ 2,480ms 2,571ms p=0.936 n=6
Req 2 - geterr 5,892ms (± 0.17%) 5,906ms (± 0.55%) ~ 5,870ms 5,965ms p=0.335 n=6
Req 3 - references 347ms (± 0.66%) 349ms (± 1.06%) ~ 346ms 356ms p=0.519 n=6
Req 4 - navto 279ms (± 0.27%) 278ms (± 0.78%) ~ 274ms 280ms p=0.858 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 74ms (± 1.57%) 72ms (± 1.43%) -2ms (- 2.47%) 71ms 74ms p=0.032 n=6
CompilerTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 2,676ms (± 0.51%) 2,665ms (± 0.34%) ~ 2,651ms 2,673ms p=0.172 n=6
Req 2 - geterr 4,438ms (± 0.36%) 4,439ms (± 0.46%) ~ 4,406ms 4,456ms p=0.689 n=6
Req 3 - references 365ms (± 0.24%) 366ms (± 0.65%) ~ 363ms 368ms p=0.373 n=6
Req 4 - navto 287ms (± 0.22%) 287ms (± 0.26%) ~ 286ms 288ms p=0.718 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 78ms (± 3.19%) 78ms (± 2.74%) ~ 76ms 81ms p=0.933 n=6
xstateTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 3,160ms (± 0.35%) 3,161ms (± 0.50%) ~ 3,143ms 3,185ms p=1.000 n=6
Req 2 - geterr 1,845ms (± 0.71%) 1,861ms (± 0.89%) ~ 1,834ms 1,875ms p=0.092 n=6
Req 3 - references 114ms (± 1.65%) 114ms (± 1.98%) ~ 112ms 118ms p=1.000 n=6
Req 4 - navto 342ms (± 0.39%) 341ms (± 0.48%) ~ 339ms 343ms p=0.216 n=6
Req 5 - completionInfo count 2,861 (± 0.00%) 2,861 (± 0.00%) ~ 2,861 2,861 p=1.000 n=6
Req 5 - completionInfo 393ms (± 1.06%) 401ms (± 0.82%) +9ms (+ 2.16%) 397ms 405ms p=0.006 n=6
Compiler-UnionsTSServer - node (v14.15.1, x64)
Req 1 - updateOpen 2,607ms (± 0.52%) 2,603ms (± 0.56%) ~ 2,584ms 2,621ms p=0.517 n=6
Req 2 - geterr 6,353ms (± 0.48%) 6,367ms (± 0.43%) ~ 6,325ms 6,390ms p=0.471 n=6
Req 3 - references 362ms (± 0.52%) 364ms (± 0.40%) ~ 362ms 366ms p=0.103 n=6
Req 4 - navto 282ms (± 0.85%) 282ms (± 1.43%) ~ 280ms 290ms p=0.366 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 96ms (± 6.11%) 101ms (± 2.06%) ~ 98ms 103ms p=0.371 n=6
CompilerTSServer - node (v14.15.1, x64)
Req 1 - updateOpen 2,831ms (± 0.59%) 2,825ms (± 0.59%) ~ 2,804ms 2,847ms p=0.630 n=6
Req 2 - geterr 4,684ms (± 2.62%) 4,716ms (± 2.42%) ~ 4,560ms 4,807ms p=0.810 n=6
Req 3 - references 389ms (± 6.97%) 379ms (± 5.51%) ~ 368ms 421ms p=0.466 n=6
Req 4 - navto 289ms (± 1.08%) 292ms (± 1.62%) ~ 285ms 297ms p=0.361 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 80ms (± 9.99%) 78ms (± 9.21%) ~ 74ms 92ms p=0.366 n=6
xstateTSServer - node (v14.15.1, x64)
Req 1 - updateOpen 3,458ms (± 0.44%) 3,444ms (± 0.42%) ~ 3,421ms 3,461ms p=0.298 n=6
Req 2 - geterr 1,869ms (± 1.26%) 1,890ms (± 1.11%) ~ 1,854ms 1,917ms p=0.149 n=6
Req 3 - references 125ms (± 0.60%) 125ms (± 1.60%) ~ 123ms 128ms p=0.676 n=6
Req 4 - navto 372ms (± 0.53%) 370ms (± 0.33%) ~ 369ms 372ms p=0.285 n=6
Req 5 - completionInfo count 2,861 (± 0.00%) 2,861 (± 0.00%) ~ 2,861 2,861 p=1.000 n=6
Req 5 - completionInfo 408ms (± 1.22%) 406ms (± 0.90%) ~ 401ms 411ms p=0.574 n=6
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-135-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v18.10.0, x64)
  • node (v16.17.1, x64)
  • node (v14.15.1, x64)
Scenarios
  • Compiler-UnionsTSServer - node (v18.10.0, x64)
  • Compiler-UnionsTSServer - node (v16.17.1, x64)
  • Compiler-UnionsTSServer - node (v14.15.1, x64)
  • CompilerTSServer - node (v18.10.0, x64)
  • CompilerTSServer - node (v16.17.1, x64)
  • CompilerTSServer - node (v14.15.1, x64)
  • xstateTSServer - node (v18.10.0, x64)
  • xstateTSServer - node (v16.17.1, x64)
  • xstateTSServer - node (v14.15.1, x64)
Benchmark Name Iterations
Current 53489 6
Baseline main 6

Startup

Comparison Report - main..53489
Metric main 53489 Delta Best Worst p-value
tsc-startup - node (v16.17.1, x64)
Execution time 141.87ms (± 0.23%) 141.27ms (± 0.20%) -0.60ms (- 0.43%) 140.63ms 146.58ms p=0.000 n=600
tsserver-startup - node (v16.17.1, x64)
Execution time 229.11ms (± 0.47%) 227.22ms (± 0.41%) -1.89ms (- 0.83%) 224.85ms 233.56ms p=0.000 n=600
tsserverlibrary-startup - node (v16.17.1, x64)
Execution time 230.78ms (± 0.38%) 227.97ms (± 0.20%) -2.81ms (- 1.22%) 226.74ms 232.94ms p=0.000 n=600
typescript-startup - node (v16.17.1, x64)
Execution time 210.94ms (± 0.35%) 209.10ms (± 0.23%) -1.85ms (- 0.88%) 207.82ms 216.36ms p=0.000 n=600
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-135-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v16.17.1, x64)
Scenarios
  • tsc-startup - node (v16.17.1, x64)
  • tsserver-startup - node (v16.17.1, x64)
  • tsserverlibrary-startup - node (v16.17.1, x64)
  • typescript-startup - node (v16.17.1, x64)
Benchmark Name Iterations
Current 53489 6
Baseline main 6

Developer Information:

Download Benchmark

@typescript-bot
Copy link
Collaborator

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

@typescript-bot
Copy link
Collaborator

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

Everything looks good!

@ericbf
Copy link
Contributor

ericbf commented Apr 3, 2023

with maybe the caveat that output arrays are unions of elements within a single array rather than unions of array types

This is kind of a big caveat, don’t you think? Filter, for example, doesn’t change the type of the array, so for it to convert A[] | B[] to (A | B)[] is very weird and could be classified as a bug if merged as is, imo. Under no normal circumstances ever would (A[] | B[]).filter return a (A | B)[]...

@RyanCavanaugh
Copy link
Member

This is kind of a big caveat, don’t you think?

I'm not sure what the proposed alternative is. If you're writing filter, you're probably writing arr.filter(x => expr), and we can't iteratively assign a type to x -- it needs to be a single type, ideally A | B.

@ericbf
Copy link
Contributor

ericbf commented Apr 3, 2023

I'm not sure what the proposed alternative is. If you're writing filter, you're probably writing arr.filter(x => expr), and we can't iteratively assign a type to x -- it needs to be a single type, ideally A | B.

For filter (and even if only for filter), I’d expect the type to be something like:

// Assuming the array is `A[] | B[]`
(predicate: (item: A | B, index: number, array: A[] | B[]) => boolean) => A[] | B[]

The type of the item in the predicate could be either A or B, but the returned array from filter would only ever be an A[] or a B[].

Granted, this current implemented is definitely a step in the right direction, much better than not working at all.

@sandersn sandersn requested a review from gabritto April 12, 2023 20:13
@weswigham
Copy link
Member Author

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 12, 2023

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 12, 2023

Hey @weswigham, 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/152278/artifacts?artifactName=tgz&fileId=F51ABFB5B241623909891BC82EFFA0E7BC9A352A55A35004D867C9BD4598367002&fileName=/typescript-5.1.0-insiders.20230412.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]".;

@weswigham
Copy link
Member Author

@andrewbranch @ahejlsberg I'm pinging more people for a second review :)

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 15, 2023

Heya @DanielRosenwasser, I've started to run the diff-based top-repos suite (tsserver) on this PR at 975ba5d. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 15, 2023

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 15, 2023

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 15, 2023

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 15, 2023

Heya @DanielRosenwasser, I've started to run the diff-based user code test suite on this PR at 975ba5d. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 15, 2023

Hey @DanielRosenwasser, 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/152478/artifacts?artifactName=tgz&fileId=8E69FF64CF161684D70F57887E9994B4BD0AD738117AA41749CFA3AE1476B7F202&fileName=/typescript-5.1.0-insiders.20230415.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

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

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Package install failed"

Otherwise...

Everything looks good!

@typescript-bot
Copy link
Collaborator

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

Everything looks good!

@typescript-bot
Copy link
Collaborator

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

Everything looks good!

@typescript-bot
Copy link
Collaborator

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

Here they are:

Compiler

Comparison Report - main..53489
Metric main 53489 Delta Best Worst p-value
Angular - node (v18.10.0, x64)
Memory used 365,213k (± 0.01%) 365,217k (± 0.01%) ~ 365,173k 365,281k p=0.810 n=6
Parse Time 3.35s (± 0.57%) 3.35s (± 0.70%) ~ 3.31s 3.37s p=0.934 n=6
Bind Time 1.11s (± 1.47%) 1.13s (± 0.93%) ~ 1.11s 1.14s p=0.250 n=6
Check Time 8.72s (± 0.29%) 8.70s (± 0.50%) ~ 8.64s 8.75s p=0.258 n=6
Emit Time 7.44s (± 0.25%) 7.48s (± 0.28%) +0.04s (+ 0.52%) 7.46s 7.51s p=0.007 n=6
Total Time 20.63s (± 0.21%) 20.65s (± 0.35%) ~ 20.54s 20.74s p=0.573 n=6
Compiler-Unions - node (v18.10.0, x64)
Memory used 191,342k (± 0.53%) 190,957k (± 0.02%) ~ 190,916k 191,002k p=0.261 n=6
Parse Time 1.49s (± 0.27%) 1.50s (± 0.60%) +0.01s (+ 0.78%) 1.49s 1.51s p=0.025 n=6
Bind Time 0.77s (± 0.53%) 0.77s (± 0.98%) ~ 0.76s 0.78s p=1.000 n=6
Check Time 9.52s (± 0.57%) 9.55s (± 0.37%) ~ 9.51s 9.59s p=0.334 n=6
Emit Time 2.73s (± 1.24%) 2.74s (± 1.12%) ~ 2.71s 2.79s p=0.565 n=6
Total Time 14.50s (± 0.49%) 14.55s (± 0.32%) ~ 14.49s 14.61s p=0.199 n=6
Monaco - node (v18.10.0, x64)
Memory used 346,495k (± 0.01%) 346,516k (± 0.01%) ~ 346,488k 346,562k p=0.173 n=6
Parse Time 2.59s (± 0.73%) 2.57s (± 1.76%) ~ 2.53s 2.63s p=0.629 n=6
Bind Time 1.01s (± 0.63%) 1.00s (± 0.41%) -0.01s (- 0.83%) 1.00s 1.01s p=0.033 n=6
Check Time 7.13s (± 0.49%) 7.12s (± 0.30%) ~ 7.09s 7.15s p=0.334 n=6
Emit Time 4.24s (± 0.55%) 4.26s (± 0.95%) ~ 4.23s 4.34s p=0.255 n=6
Total Time 14.97s (± 0.44%) 14.96s (± 0.42%) ~ 14.90s 15.04s p=1.000 n=6
TFS - node (v18.10.0, x64)
Memory used 300,717k (± 0.01%) 300,703k (± 0.01%) ~ 300,686k 300,743k p=0.336 n=6
Parse Time 2.04s (± 1.34%) 2.06s (± 1.11%) ~ 2.04s 2.10s p=0.295 n=6
Bind Time 1.14s (± 1.24%) 1.14s (± 0.55%) ~ 1.13s 1.15s p=1.000 n=6
Check Time 6.53s (± 0.51%) 6.53s (± 0.34%) ~ 6.49s 6.55s p=0.808 n=6
Emit Time 3.86s (± 0.81%) 3.86s (± 1.20%) ~ 3.81s 3.92s p=0.871 n=6
Total Time 13.58s (± 0.51%) 13.59s (± 0.34%) ~ 13.53s 13.66s p=0.572 n=6
material-ui - node (v18.10.0, x64)
Memory used 481,862k (± 0.01%) 481,833k (± 0.00%) ~ 481,810k 481,856k p=0.127 n=6
Parse Time 3.03s (± 0.70%) 3.03s (± 0.54%) ~ 3.01s 3.05s p=0.745 n=6
Bind Time 0.91s (± 2.56%) 0.91s (± 1.61%) ~ 0.90s 0.94s p=0.796 n=6
Check Time 16.77s (± 0.46%) 16.82s (± 0.58%) ~ 16.72s 16.98s p=0.378 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 20.72s (± 0.29%) 20.77s (± 0.50%) ~ 20.66s 20.94s p=0.521 n=6
xstate - node (v18.10.0, x64)
Memory used 561,801k (± 0.02%) 561,819k (± 0.03%) ~ 561,645k 562,132k p=0.936 n=6
Parse Time 3.81s (± 0.91%) 3.82s (± 0.52%) ~ 3.80s 3.85s p=0.418 n=6
Bind Time 1.65s (± 0.71%) 1.65s (± 0.46%) ~ 1.64s 1.66s p=0.933 n=6
Check Time 2.80s (± 0.73%) 2.80s (± 1.07%) ~ 2.77s 2.84s p=0.936 n=6
Emit Time 0.08s (± 0.00%) 0.08s (± 0.00%) ~ 0.08s 0.08s p=1.000 n=6
Total Time 8.34s (± 0.65%) 8.36s (± 0.44%) ~ 8.31s 8.41s p=0.688 n=6
Angular - node (v16.17.1, x64)
Memory used 364,602k (± 0.00%) 364,606k (± 0.01%) ~ 364,582k 364,636k p=0.688 n=6
Parse Time 3.54s (± 0.71%) 3.54s (± 0.79%) ~ 3.50s 3.57s p=0.807 n=6
Bind Time 1.18s (± 1.39%) 1.18s (± 0.76%) ~ 1.17s 1.19s p=0.560 n=6
Check Time 9.50s (± 0.32%) 9.47s (± 0.29%) ~ 9.44s 9.51s p=0.225 n=6
Emit Time 7.92s (± 0.68%) 7.95s (± 0.40%) ~ 7.91s 7.99s p=0.125 n=6
Total Time 22.14s (± 0.26%) 22.15s (± 0.25%) ~ 22.05s 22.19s p=0.809 n=6
Compiler-Unions - node (v16.17.1, x64)
Memory used 193,129k (± 0.69%) 192,613k (± 0.03%) ~ 192,537k 192,666k p=0.810 n=6
Parse Time 1.59s (± 0.51%) 1.57s (± 1.86%) ~ 1.53s 1.60s p=0.532 n=6
Bind Time 0.82s (± 0.50%) 0.82s (± 0.66%) ~ 0.82s 0.83s p=0.282 n=6
Check Time 10.22s (± 0.44%) 10.24s (± 0.64%) ~ 10.12s 10.31s p=0.227 n=6
Emit Time 2.99s (± 0.72%) 3.00s (± 0.93%) ~ 2.97s 3.05s p=0.290 n=6
Total Time 15.61s (± 0.31%) 15.64s (± 0.44%) ~ 15.53s 15.72s p=0.336 n=6
Monaco - node (v16.17.1, x64)
Memory used 345,786k (± 0.01%) 345,792k (± 0.01%) ~ 345,769k 345,821k p=0.521 n=6
Parse Time 2.72s (± 0.19%) 2.72s (± 0.43%) ~ 2.71s 2.74s p=0.929 n=6
Bind Time 1.08s (± 0.48%) 1.08s (± 0.70%) ~ 1.07s 1.09s p=0.784 n=6
Check Time 7.85s (± 0.31%) 7.83s (± 0.50%) ~ 7.80s 7.90s p=0.107 n=6
Emit Time 4.48s (± 0.74%) 4.48s (± 0.68%) ~ 4.44s 4.52s p=0.936 n=6
Total Time 16.14s (± 0.30%) 16.11s (± 0.44%) ~ 16.06s 16.25s p=0.260 n=6
TFS - node (v16.17.1, x64)
Memory used 300,051k (± 0.01%) 300,063k (± 0.00%) ~ 300,049k 300,082k p=0.748 n=6
Parse Time 2.16s (± 0.49%) 2.16s (± 0.41%) ~ 2.15s 2.17s p=0.452 n=6
Bind Time 1.24s (± 0.85%) 1.23s (± 1.22%) ~ 1.21s 1.25s p=1.000 n=6
Check Time 7.19s (± 0.43%) 7.16s (± 0.16%) ~ 7.15s 7.18s p=0.084 n=6
Emit Time 4.34s (± 0.51%) 4.33s (± 0.60%) ~ 4.29s 4.36s p=0.686 n=6
Total Time 14.91s (± 0.31%) 14.89s (± 0.32%) ~ 14.82s 14.95s p=0.377 n=6
material-ui - node (v16.17.1, x64)
Memory used 481,178k (± 0.01%) 481,213k (± 0.02%) ~ 481,093k 481,298k p=0.689 n=6
Parse Time 3.24s (± 0.41%) 3.24s (± 0.42%) ~ 3.23s 3.27s p=0.868 n=6
Bind Time 0.95s (± 0.57%) 0.95s (± 0.54%) -0.01s (- 0.87%) 0.94s 0.95s p=0.038 n=6
Check Time 17.80s (± 0.43%) 17.84s (± 0.26%) ~ 17.76s 17.88s p=0.261 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 22.00s (± 0.38%) 22.03s (± 0.19%) ~ 21.97s 22.07s p=0.297 n=6
xstate - node (v16.17.1, x64)
Memory used 559,536k (± 0.03%) 559,468k (± 0.03%) ~ 559,336k 559,705k p=0.574 n=6
Parse Time 3.99s (± 0.25%) 4.00s (± 0.43%) ~ 3.98s 4.02s p=0.154 n=6
Bind Time 1.75s (± 0.43%) 1.75s (± 0.23%) ~ 1.75s 1.76s p=0.389 n=6
Check Time 3.02s (± 0.34%) 3.01s (± 0.18%) -0.01s (- 0.39%) 3.00s 3.01s p=0.047 n=6
Emit Time 0.09s (± 0.00%) 0.09s (± 0.00%) ~ 0.09s 0.09s p=1.000 n=6
Total Time 8.84s (± 0.23%) 8.85s (± 0.20%) ~ 8.83s 8.88s p=0.455 n=6
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-135-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v18.10.0, x64)
  • node (v16.17.1, x64)
  • node (v14.21.3, x64)
Scenarios
  • Angular - node (v18.10.0, x64)
  • Angular - node (v16.17.1, x64)
  • Angular - node (v14.21.3, x64)
  • Compiler-Unions - node (v18.10.0, x64)
  • Compiler-Unions - node (v16.17.1, x64)
  • Compiler-Unions - node (v14.21.3, x64)
  • Monaco - node (v18.10.0, x64)
  • Monaco - node (v16.17.1, x64)
  • Monaco - node (v14.21.3, x64)
  • TFS - node (v18.10.0, x64)
  • TFS - node (v16.17.1, x64)
  • TFS - node (v14.21.3, x64)
  • material-ui - node (v18.10.0, x64)
  • material-ui - node (v16.17.1, x64)
  • material-ui - node (v14.21.3, x64)
  • xstate - node (v18.10.0, x64)
  • xstate - node (v16.17.1, x64)
  • xstate - node (v14.21.3, x64)
Benchmark Name Iterations
Current 53489 6
Baseline main 6

TSServer

Comparison Report - main..53489
Metric main 53489 Delta Best Worst p-value
Compiler-UnionsTSServer - node (v18.10.0, x64)
Req 1 - updateOpen 2,393ms (± 0.32%) 2,407ms (± 0.77%) ~ 2,386ms 2,438ms p=0.149 n=6
Req 2 - geterr 5,605ms (± 0.83%) 5,587ms (± 1.66%) ~ 5,412ms 5,662ms p=0.936 n=6
Req 3 - references 339ms (± 0.48%) 340ms (± 1.14%) ~ 338ms 348ms p=0.511 n=6
Req 4 - navto 284ms (± 0.49%) 286ms (± 1.00%) ~ 283ms 291ms p=0.101 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 84ms (± 0.75%) 82ms (± 8.61%) ~ 68ms 88ms p=1.000 n=6
CompilerTSServer - node (v18.10.0, x64)
Req 1 - updateOpen 2,504ms (± 1.25%) 2,517ms (± 1.47%) ~ 2,471ms 2,555ms p=0.471 n=6
Req 2 - geterr 4,214ms (± 0.42%) 4,218ms (± 1.30%) ~ 4,111ms 4,258ms p=0.297 n=6
Req 3 - references 343ms (± 0.39%) 351ms (± 5.40%) ~ 341ms 390ms p=0.249 n=6
Req 4 - navto 290ms (± 1.44%) 288ms (± 0.83%) ~ 283ms 289ms p=0.720 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 64ms (± 4.56%) 65ms (± 5.99%) ~ 62ms 70ms p=0.933 n=6
xstateTSServer - node (v18.10.0, x64)
Req 1 - updateOpen 3,025ms (± 0.38%) 3,018ms (± 0.19%) ~ 3,009ms 3,025ms p=0.295 n=6
Req 2 - geterr 1,597ms (± 0.76%) 1,605ms (± 0.66%) ~ 1,598ms 1,626ms p=0.572 n=6
Req 3 - references 108ms (± 4.05%) 108ms (± 2.68%) ~ 105ms 113ms p=0.622 n=6
Req 4 - navto 364ms (± 0.33%) 362ms (± 0.48%) ~ 360ms 364ms p=0.166 n=6
Req 5 - completionInfo count 2,862 (± 0.00%) 2,862 (± 0.00%) ~ 2,862 2,862 p=1.000 n=6
Req 5 - completionInfo 374ms (± 1.34%) 377ms (± 2.25%) ~ 362ms 386ms p=0.261 n=6
Compiler-UnionsTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 2,522ms (± 0.59%) 2,532ms (± 0.69%) ~ 2,503ms 2,554ms p=0.298 n=6
Req 2 - geterr 6,016ms (± 0.58%) 6,025ms (± 0.78%) ~ 5,978ms 6,107ms p=1.000 n=6
Req 3 - references 352ms (± 0.63%) 353ms (± 0.74%) ~ 349ms 357ms p=0.739 n=6
Req 4 - navto 287ms (± 1.73%) 285ms (± 1.69%) ~ 280ms 293ms p=0.807 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 90ms (± 5.22%) 89ms (± 5.56%) ~ 80ms 92ms p=0.865 n=6
CompilerTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 2,661ms (± 1.15%) 2,682ms (± 0.89%) ~ 2,644ms 2,713ms p=0.199 n=6
Req 2 - geterr 4,620ms (± 0.51%) 4,631ms (± 0.38%) ~ 4,615ms 4,654ms p=0.470 n=6
Req 3 - references 358ms (± 0.51%) 360ms (± 0.49%) ~ 359ms 363ms p=0.088 n=6
Req 4 - navto 281ms (± 0.84%) 282ms (± 1.04%) ~ 278ms 284ms p=0.456 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 68ms (± 1.24%) 68ms (± 1.72%) ~ 66ms 69ms p=0.555 n=6
xstateTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 3,176ms (± 0.28%) 3,182ms (± 0.32%) ~ 3,172ms 3,197ms p=0.378 n=6
Req 2 - geterr 1,745ms (± 0.86%) 1,749ms (± 0.79%) ~ 1,737ms 1,770ms p=0.748 n=6
Req 3 - references 120ms (± 1.23%) 120ms (± 1.39%) ~ 118ms 123ms p=0.934 n=6
Req 4 - navto 342ms (± 1.04%) 341ms (± 0.34%) ~ 339ms 342ms p=0.868 n=6
Req 5 - completionInfo count 2,862 (± 0.00%) 2,862 (± 0.00%) ~ 2,862 2,862 p=1.000 n=6
Req 5 - completionInfo 390ms (± 0.78%) 394ms (± 0.89%) ~ 389ms 398ms p=0.106 n=6
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-135-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v18.10.0, x64)
  • node (v16.17.1, x64)
  • node (v14.21.3, x64)
Scenarios
  • Compiler-UnionsTSServer - node (v18.10.0, x64)
  • Compiler-UnionsTSServer - node (v16.17.1, x64)
  • Compiler-UnionsTSServer - node (v14.21.3, x64)
  • CompilerTSServer - node (v18.10.0, x64)
  • CompilerTSServer - node (v16.17.1, x64)
  • CompilerTSServer - node (v14.21.3, x64)
  • xstateTSServer - node (v18.10.0, x64)
  • xstateTSServer - node (v16.17.1, x64)
  • xstateTSServer - node (v14.21.3, x64)
Benchmark Name Iterations
Current 53489 6
Baseline main 6

Startup

Comparison Report - main..53489
Metric main 53489 Delta Best Worst p-value
tsc-startup - node (v16.17.1, x64)
Execution time 141.84ms (± 0.16%) 142.14ms (± 0.20%) +0.29ms (+ 0.21%) 141.48ms 147.46ms p=0.000 n=600
tsserver-startup - node (v16.17.1, x64)
Execution time 220.14ms (± 0.16%) 220.89ms (± 0.19%) +0.75ms (+ 0.34%) 219.95ms 230.61ms p=0.000 n=600
tsserverlibrary-startup - node (v16.17.1, x64)
Execution time 221.64ms (± 0.16%) 222.09ms (± 0.16%) +0.45ms (+ 0.20%) 221.29ms 228.00ms p=0.000 n=600
typescript-startup - node (v16.17.1, x64)
Execution time 203.43ms (± 0.15%) 203.86ms (± 0.16%) +0.43ms (+ 0.21%) 203.10ms 209.16ms p=0.000 n=600
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-135-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v16.17.1, x64)
Scenarios
  • tsc-startup - node (v16.17.1, x64)
  • tsserver-startup - node (v16.17.1, x64)
  • tsserverlibrary-startup - node (v16.17.1, x64)
  • typescript-startup - node (v16.17.1, x64)
Benchmark Name Iterations
Current 53489 6
Baseline main 6

Developer Information:

Download Benchmark

@typescript-bot
Copy link
Collaborator

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

@typescript-bot
Copy link
Collaborator

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

Everything looks good!

@ialexryan
Copy link
Contributor

Hurray! Thank you so much @weswigham 🎉 🙇🏻

@thorn0
Copy link

thorn0 commented Jun 18, 2023

Seems to fix #42646

@craigphicks
Copy link

I'm not sure what the proposed alternative is. If you're writing filter, you're probably writing arr.filter(x => expr), and we can't iteratively assign a type to x -- it needs to be a single type, ideally A | B.

For filter (and even if only for filter), I’d expect the type to be something like:

// Assuming the array is `A[] | B[]`
(predicate: (item: A | B, index: number, array: A[] | B[]) => boolean) => A[] | B[]

That functional definition of filter is not correct, it should be union of function definitions, one for each component type A and B. Otherwise a valid predicate like (item: A, index: number, array: A[]) will fail, and in fact in 5.2.2 it is failing - see #55777.

@ericbf
Copy link
Contributor

ericbf commented Sep 18, 2023

I'm not sure what the proposed alternative is. If you're writing filter, you're probably writing arr.filter(x => expr), and we can't iteratively assign a type to x -- it needs to be a single type, ideally A | B.

For filter (and even if only for filter), I’d expect the type to be something like:

// Assuming the array is `A[] | B[]`
(predicate: (item: A | B, index: number, array: A[] | B[]) => boolean) => A[] | B[]

That functional definition of filter is not correct, it should be union of function definitions, one for each component type A and B. Otherwise a valid predicate like (item: A, index: number, array: A[]) will fail, and in fact in 5.2.2 it is failing - see #55777.

The way I see it, that value predicate should fail. There is no guarantee from a type system perspective that item is an A, so a predicate of (item: A...) isn’t compatible. That was why I suggested at least the proper return type (there is no situation under which filter would ever turn an A[] into an (A | B)[]).

In the linked issue, however, you have don’t just use a predicate of that single type ((item: A, index: number, array: A[]), which should and would fail by itself), but an overloaded function predicate, which is a different story.

BTW, usually it’s not ideal to start competing conversations in different issues, so let’s carry this on in the linked issue completely?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

.every() .find() .filter() methods fail with "This expression is not callable." error on union of array types
10 participants