Skip to content

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

Merged
Wesley Wigham (weswigham) merged 1 commit into
microsoft:mainfrom
weswigham:array-signature-fallbacks
May 16, 2023
Merged

Add fallback logic for generating signatures for unions of array members#53489
Wesley Wigham (weswigham) merged 1 commit into
microsoft:mainfrom
weswigham:array-signature-fallbacks

Conversation

@weswigham

Copy link
Copy Markdown
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: es6interfaceFizz{id: number;fizz: string;}interfaceBuzz{id: number;buzz: string;}([]asFizz[]|Buzz[]).filter(item=>item.id<5);([]asFizz[]|readonlyBuzz[]).filter(item=>item.id<5);([]asFizz[]|Buzz[]).find(item=>item);declarefunctionisFizz(x: unknown): x is Fizz;([]asFizz[]|Buzz[]).find(isFizz);declarefunctionisBuzz(x: unknown): x is Buzz;([]asFizz[]|Buzz[]).find(isBuzz);([]asFizz[]|Buzz[]).every(item=>item.id<5);([]asFizz[]|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.

@weswigham

Copy link
Copy Markdown
MemberAuthor

@typescript-bot

TypeScript Bot (typescript-bot) commented Mar 24, 2023

Copy link
Copy Markdown
Contributor

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

@typescript-bot

TypeScript Bot (typescript-bot) commented Mar 24, 2023

Copy link
Copy Markdown
Contributor

Heya Wesley Wigham (@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

TypeScript Bot (typescript-bot) commented Mar 24, 2023

Copy link
Copy Markdown
Contributor

Heya Wesley Wigham (@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

TypeScript Bot (typescript-bot) commented Mar 24, 2023

Copy link
Copy Markdown
Contributor

Heya Wesley Wigham (@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

TypeScript Bot (typescript-bot) commented Mar 24, 2023

Copy link
Copy Markdown
Contributor

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

@typescript-bot

TypeScript Bot (typescript-bot) commented Mar 24, 2023

Copy link
Copy Markdown
Contributor

Hey Wesley Wigham (@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/pr-build@5.1.0-pr-53489-6".;

@typescript-bot

Copy link
Copy Markdown
Contributor

Wesley Wigham (@weswigham)
The results of the perf run you requested are in!

Here they are:

Compiler

Comparison Report - main..53489
Metricmain53489DeltaBestWorstp-value
Angular - node (v18.10.0, x64)
Memory used362,093k (± 0.01%)362,102k (± 0.01%)~362,064k362,128kp=0.575 n=6
Parse Time3.40s (± 0.29%)3.38s (± 0.49%)-0.02s (- 0.64%)3.35s3.40sp=0.022 n=6
Bind Time1.12s (± 0.46%)1.12s (± 0.00%)~1.12s1.12sp=0.174 n=6
Check Time8.72s (± 0.28%)8.70s (± 0.54%)~8.64s8.76sp=0.568 n=6
Emit Time7.54s (± 0.57%)7.49s (± 0.76%)~7.38s7.55sp=0.168 n=6
Total Time20.78s (± 0.28%)20.69s (± 0.35%)~20.62s20.81sp=0.064 n=6
Compiler-Unions - node (v18.10.0, x64)
Memory used193,687k (± 1.63%)191,777k (± 1.22%)~190,763k196,565kp=0.575 n=6
Parse Time1.50s (± 0.60%)1.49s (± 0.78%)~1.48s1.51sp=0.214 n=6
Bind Time0.77s (± 0.97%)0.77s (± 0.67%)~0.76s0.77sp=0.241 n=6
Check Time9.66s (± 0.53%)9.71s (± 0.76%)~9.60s9.78sp=0.334 n=6
Emit Time2.73s (± 0.89%)2.71s (± 0.28%)~2.70s2.72sp=0.331 n=6
Total Time14.66s (± 0.53%)14.68s (± 0.57%)~14.57s14.78sp=0.748 n=6
Monaco - node (v18.10.0, x64)
Memory used346,449k (± 0.01%)346,442k (± 0.01%)~346,363k346,502kp=1.000 n=6
Parse Time2.60s (± 0.45%)2.60s (± 1.01%)~2.56s2.63sp=0.513 n=6
Bind Time1.00s (± 0.51%)1.01s (± 1.03%)~1.00s1.03sp=0.051 n=6
Check Time7.14s (± 0.44%)7.11s (± 0.39%)~7.07s7.14sp=0.418 n=6
Emit Time4.25s (± 0.59%)4.26s (± 0.38%)~4.23s4.28sp=0.870 n=6
Total Time14.99s (± 0.35%)14.98s (± 0.13%)~14.96s15.01sp=0.627 n=6
TFS - node (v18.10.0, x64)
Memory used300,672k (± 0.01%)300,691k (± 0.01%)~300,675k300,728kp=0.230 n=6
Parse Time2.08s (± 0.77%)2.06s (± 1.43%)~2.01s2.09sp=0.323 n=6
Bind Time1.14s (± 0.55%)1.14s (± 0.66%)~1.13s1.15sp=0.718 n=6
Check Time6.55s (± 0.48%)6.54s (± 0.69%)~6.47s6.59sp=1.000 n=6
Emit Time3.86s (± 0.35%)3.84s (± 0.97%)~3.80s3.89sp=0.293 n=6
Total Time13.63s (± 0.34%)13.58s (± 0.74%)~13.41s13.71sp=0.371 n=6
material-ui - node (v18.10.0, x64)
Memory used477,137k (± 0.01%)477,122k (± 0.01%)~477,096k477,167kp=0.521 n=6
Parse Time3.01s (± 2.10%)2.99s (± 2.79%)~2.91s3.11sp=0.575 n=6
Bind Time1.02s (± 7.50%)0.99s (± 8.85%)~0.91s1.08sp=0.685 n=6
Check Time17.45s (± 1.04%)17.13s (± 0.45%)-0.32s (- 1.82%)17.06s17.27sp=0.008 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time21.48s (± 0.89%)21.12s (± 0.45%)-0.36s (- 1.68%)20.99s21.27sp=0.008 n=6
xstate - node (v18.10.0, x64)
Memory used552,893k (± 0.02%)552,929k (± 0.02%)~552,827k553,060kp=0.521 n=6
Parse Time3.80s (± 0.59%)3.79s (± 0.80%)~3.75s3.82sp=0.331 n=6
Bind Time1.71s (± 0.68%)1.70s (± 0.61%)~1.69s1.72sp=0.241 n=6
Check Time2.87s (± 0.92%)2.86s (± 0.41%)~2.84s2.87sp=0.936 n=6
Emit Time0.08s (± 0.00%)0.08s (± 0.00%)~0.08s0.08sp=1.000 n=6
Total Time8.47s (± 0.60%)8.43s (± 0.43%)~8.38s8.47sp=0.296 n=6
Angular - node (v16.17.1, x64)
Memory used361,441k (± 0.01%)361,452k (± 0.01%)~361,428k361,503kp=0.521 n=6
Parse Time3.52s (± 0.47%)3.53s (± 0.87%)~3.51s3.59sp=0.933 n=6
Bind Time1.19s (± 0.69%)1.19s (± 0.63%)~1.18s1.20sp=0.729 n=6
Check Time9.55s (± 0.55%)9.52s (± 0.53%)~9.46s9.58sp=0.296 n=6
Emit Time7.96s (± 0.99%)7.93s (± 0.34%)~7.89s7.96sp=0.686 n=6
Total Time22.22s (± 0.60%)22.16s (± 0.20%)~22.09s22.22sp=0.810 n=6
Compiler-Unions - node (v16.17.1, x64)
Memory used193,061k (± 0.72%)192,525k (± 0.02%)~192,486k192,573kp=0.298 n=6
Parse Time1.58s (± 1.26%)1.59s (± 0.66%)~1.58s1.61sp=0.217 n=6
Bind Time0.82s (± 0.50%)0.82s (± 0.50%)~0.82s0.83sp=1.000 n=6
Check Time10.37s (± 0.65%)10.34s (± 0.34%)~10.30s10.40sp=0.295 n=6
Emit Time3.00s (± 0.86%)2.99s (± 0.65%)~2.97s3.02sp=0.414 n=6
Total Time15.78s (± 0.58%)15.76s (± 0.32%)~15.70s15.83sp=0.520 n=6
Monaco - node (v16.17.1, x64)
Memory used345,732k (± 0.01%)345,727k (± 0.01%)~345,707k345,761kp=0.689 n=6
Parse Time2.74s (± 1.32%)2.73s (± 0.54%)~2.72s2.76sp=0.566 n=6
Bind Time1.08s (± 1.26%)1.09s (± 0.58%)~1.08s1.10sp=0.388 n=6
Check Time7.82s (± 0.39%)7.82s (± 0.61%)~7.77s7.90sp=0.469 n=6
Emit Time4.48s (± 0.94%)4.48s (± 1.08%)~4.42s4.55sp=1.000 n=6
Total Time16.12s (± 0.54%)16.11s (± 0.61%)~16.01s16.27sp=0.688 n=6
TFS - node (v16.17.1, x64)
Memory used300,022k (± 0.01%)300,021k (± 0.00%)~300,000k300,035kp=0.936 n=6
Parse Time2.19s (± 0.80%)2.17s (± 0.39%)-0.02s (- 0.99%)2.16s2.18sp=0.016 n=6
Bind Time1.24s (± 1.18%)1.24s (± 1.19%)~1.22s1.25sp=0.737 n=6
Check Time7.22s (± 0.82%)7.21s (± 0.44%)~7.16s7.26sp=1.000 n=6
Emit Time4.32s (± 1.00%)4.32s (± 0.63%)~4.29s4.36sp=0.936 n=6
Total Time14.97s (± 0.64%)14.93s (± 0.21%)~14.88s14.97sp=0.336 n=6
material-ui - node (v16.17.1, x64)
Memory used476,422k (± 0.01%)476,431k (± 0.01%)~476,389k476,488kp=0.936 n=6
Parse Time3.20s (± 1.21%)3.20s (± 1.14%)~3.13s3.23sp=0.871 n=6
Bind Time0.97s (± 2.06%)0.96s (± 1.02%)~0.95s0.98sp=0.591 n=6
Check Time18.14s (± 0.63%)18.26s (± 0.64%)~18.11s18.42sp=0.228 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time22.31s (± 0.48%)22.42s (± 0.61%)~22.25s22.61sp=0.173 n=6
xstate - node (v16.17.1, x64)
Memory used550,479k (± 0.01%)550,541k (± 0.02%)~550,464k550,797kp=0.748 n=6
Parse Time3.95s (± 0.49%)3.94s (± 0.30%)~3.93s3.96sp=0.226 n=6
Bind Time1.79s (± 0.82%)1.79s (± 0.45%)~1.78s1.80sp=1.000 n=6
Check Time3.11s (± 0.64%)3.10s (± 0.41%)~3.08s3.11sp=0.462 n=6
Emit Time0.09s (± 4.45%)0.09s (± 4.45%)~0.09s0.10sp=1.000 n=6
Total Time8.94s (± 0.36%)8.92s (± 0.34%)~8.88s8.96sp=0.521 n=6
Angular - node (v14.15.1, x64)
Memory used355,325k (± 0.00%)355,333k (± 0.00%)~355,323k355,338kp=0.128 n=6
Parse Time3.63s (± 0.81%)3.58s (± 0.23%)-0.04s (- 1.15%)3.58s3.60sp=0.011 n=6
Bind Time1.23s (± 0.89%)1.23s (± 0.61%)~1.22s1.24sp=1.000 n=6
Check Time9.92s (± 0.24%)9.90s (± 0.36%)~9.83s9.93sp=0.416 n=6
Emit Time8.36s (± 0.65%)8.35s (± 1.06%)~8.27s8.50sp=0.469 n=6
Total Time23.13s (± 0.20%)23.06s (± 0.44%)~22.94s23.23sp=0.173 n=6
Compiler-Unions - node (v14.15.1, x64)
Memory used187,755k (± 0.01%)188,212k (± 0.62%)~187,556k190,602kp=0.378 n=6
Parse Time1.61s (± 0.75%)1.61s (± 0.85%)~1.59s1.63sp=1.000 n=6
Bind Time0.85s (± 1.15%)0.85s (± 0.74%)~0.84s0.86sp=1.000 n=6
Check Time10.50s (± 0.73%)10.52s (± 0.47%)~10.45s10.60sp=0.871 n=6
Emit Time3.12s (± 0.43%)3.20s (± 3.64%)~3.11s3.42sp=0.221 n=6
Total Time16.07s (± 0.44%)16.17s (± 0.72%)~16.03s16.37sp=0.173 n=6
Monaco - node (v14.15.1, x64)
Memory used340,596k (± 0.01%)340,629k (± 0.00%)+33k (+ 0.01%)340,607k340,641kp=0.020 n=6
Parse Time2.84s (± 0.35%)2.82s (± 0.43%)-0.02s (- 0.88%)2.80s2.83sp=0.011 n=6
Bind Time1.11s (± 0.95%)1.10s (± 0.37%)~1.09s1.10sp=0.209 n=6
Check Time8.17s (± 0.48%)8.17s (± 0.33%)~8.14s8.20sp=1.000 n=6
Emit Time4.68s (± 0.92%)4.69s (± 0.59%)~4.66s4.73sp=0.469 n=6
Total Time16.80s (± 0.36%)16.78s (± 0.25%)~16.75s16.86sp=0.293 n=6
TFS - node (v14.15.1, x64)
Memory used295,093k (± 0.01%)295,088k (± 0.01%)~295,058k295,114kp=0.748 n=6
Parse Time2.40s (± 0.73%)2.38s (± 0.49%)~2.36s2.39sp=0.072 n=6
Bind Time1.06s (± 0.38%)1.06s (± 0.49%)~1.06s1.07sp=0.595 n=6
Check Time7.52s (± 0.72%)7.50s (± 0.16%)~7.49s7.52sp=0.327 n=6
Emit Time4.30s (± 0.80%)4.28s (± 0.34%)~4.26s4.30sp=0.259 n=6
Total Time15.29s (± 0.38%)15.22s (± 0.20%)~15.17s15.25sp=0.090 n=6
material-ui - node (v14.15.1, x64)
Memory used471,990k (± 0.00%)471,947k (± 0.00%)-43k (- 0.01%)471,911k471,969kp=0.013 n=6
Parse Time3.36s (± 0.51%)3.35s (± 0.51%)~3.33s3.38sp=0.411 n=6
Bind Time1.01s (± 0.51%)1.00s (± 0.82%)-0.01s (- 0.99%)0.99s1.01sp=0.050 n=6
Check Time19.20s (± 0.61%)19.10s (± 0.19%)~19.04s19.13sp=0.065 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time23.57s (± 0.49%)23.45s (± 0.24%)~23.36s23.52sp=0.054 n=6
xstate - node (v14.15.1, x64)
Memory used539,174k (± 0.00%)539,200k (± 0.00%)~539,171k539,225kp=0.127 n=6
Parse Time4.24s (± 0.41%)4.24s (± 0.82%)~4.20s4.29sp=0.629 n=6
Bind Time1.68s (± 0.58%)1.69s (± 0.90%)~1.67s1.71sp=0.801 n=6
Check Time3.22s (± 0.48%)3.23s (± 0.73%)~3.19s3.25sp=0.684 n=6
Emit Time0.09s (± 0.00%)0.09s (± 0.00%)~0.09s0.09sp=1.000 n=6
Total Time9.22s (± 0.14%)9.24s (± 0.78%)~9.15s9.32sp=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)
BenchmarkNameIterations
Current534896
Baselinemain6

TSServer

Comparison Report - main..53489
Metricmain53489DeltaBestWorstp-value
Compiler-UnionsTSServer - node (v18.10.0, x64)
Req 1 - updateOpen2,402ms (± 0.64%)2,391ms (± 0.52%)~2,372ms2,411msp=0.423 n=6
Req 2 - geterr5,525ms (± 0.37%)5,545ms (± 0.51%)~5,513ms5,595msp=0.298 n=6
Req 3 - references338ms (± 1.66%)338ms (± 1.55%)~334ms348msp=1.000 n=6
Req 4 - navto281ms (± 0.35%)280ms (± 0.60%)~278ms282msp=0.318 n=6
Req 5 - completionInfo count1,356 (± 0.00%)1,356 (± 0.00%)~1,3561,356p=1.000 n=6
Req 5 - completionInfo82ms (± 3.53%)83ms (± 2.73%)~78ms84msp=1.000 n=6
CompilerTSServer - node (v18.10.0, x64)
Req 1 - updateOpen2,534ms (± 1.20%)2,545ms (± 1.36%)~2,502ms2,591msp=0.471 n=6
Req 2 - geterr4,066ms (± 0.48%)4,070ms (± 0.56%)~4,042ms4,103msp=0.748 n=6
Req 3 - references349ms (± 1.60%)352ms (± 0.47%)~350ms354msp=0.685 n=6
Req 4 - navto289ms (± 0.68%)289ms (± 0.90%)~285ms293msp=1.000 n=6
Req 5 - completionInfo count1,518 (± 0.00%)1,518 (± 0.00%)~1,5181,518p=1.000 n=6
Req 5 - completionInfo78ms (± 7.29%)80ms (± 3.98%)~76ms86msp=0.798 n=6
xstateTSServer - node (v18.10.0, x64)
Req 1 - updateOpen3,026ms (± 0.64%)3,018ms (± 1.00%)~2,984ms3,061msp=0.810 n=6
Req 2 - geterr1,695ms (± 1.79%)1,704ms (± 0.79%)~1,680ms1,719msp=0.173 n=6
Req 3 - references107ms (± 0.59%)107ms (± 1.38%)~104ms108msp=0.787 n=6
Req 4 - navto358ms (± 0.66%)357ms (± 0.60%)~355ms360msp=0.627 n=6
Req 5 - completionInfo count2,861 (± 0.00%)2,861 (± 0.00%)~2,8612,861p=1.000 n=6
Req 5 - completionInfo381ms (± 2.07%)393ms (± 5.30%)~379ms433msp=0.261 n=6
Compiler-UnionsTSServer - node (v16.17.1, x64)
Req 1 - updateOpen2,511ms (± 0.89%)2,517ms (± 1.26%)~2,480ms2,571msp=0.936 n=6
Req 2 - geterr5,892ms (± 0.17%)5,906ms (± 0.55%)~5,870ms5,965msp=0.335 n=6
Req 3 - references347ms (± 0.66%)349ms (± 1.06%)~346ms356msp=0.519 n=6
Req 4 - navto279ms (± 0.27%)278ms (± 0.78%)~274ms280msp=0.858 n=6
Req 5 - completionInfo count1,356 (± 0.00%)1,356 (± 0.00%)~1,3561,356p=1.000 n=6
Req 5 - completionInfo74ms (± 1.57%)72ms (± 1.43%)-2ms (- 2.47%)71ms74msp=0.032 n=6
CompilerTSServer - node (v16.17.1, x64)
Req 1 - updateOpen2,676ms (± 0.51%)2,665ms (± 0.34%)~2,651ms2,673msp=0.172 n=6
Req 2 - geterr4,438ms (± 0.36%)4,439ms (± 0.46%)~4,406ms4,456msp=0.689 n=6
Req 3 - references365ms (± 0.24%)366ms (± 0.65%)~363ms368msp=0.373 n=6
Req 4 - navto287ms (± 0.22%)287ms (± 0.26%)~286ms288msp=0.718 n=6
Req 5 - completionInfo count1,518 (± 0.00%)1,518 (± 0.00%)~1,5181,518p=1.000 n=6
Req 5 - completionInfo78ms (± 3.19%)78ms (± 2.74%)~76ms81msp=0.933 n=6
xstateTSServer - node (v16.17.1, x64)
Req 1 - updateOpen3,160ms (± 0.35%)3,161ms (± 0.50%)~3,143ms3,185msp=1.000 n=6
Req 2 - geterr1,845ms (± 0.71%)1,861ms (± 0.89%)~1,834ms1,875msp=0.092 n=6
Req 3 - references114ms (± 1.65%)114ms (± 1.98%)~112ms118msp=1.000 n=6
Req 4 - navto342ms (± 0.39%)341ms (± 0.48%)~339ms343msp=0.216 n=6
Req 5 - completionInfo count2,861 (± 0.00%)2,861 (± 0.00%)~2,8612,861p=1.000 n=6
Req 5 - completionInfo393ms (± 1.06%)401ms (± 0.82%)+9ms (+ 2.16%)397ms405msp=0.006 n=6
Compiler-UnionsTSServer - node (v14.15.1, x64)
Req 1 - updateOpen2,607ms (± 0.52%)2,603ms (± 0.56%)~2,584ms2,621msp=0.517 n=6
Req 2 - geterr6,353ms (± 0.48%)6,367ms (± 0.43%)~6,325ms6,390msp=0.471 n=6
Req 3 - references362ms (± 0.52%)364ms (± 0.40%)~362ms366msp=0.103 n=6
Req 4 - navto282ms (± 0.85%)282ms (± 1.43%)~280ms290msp=0.366 n=6
Req 5 - completionInfo count1,356 (± 0.00%)1,356 (± 0.00%)~1,3561,356p=1.000 n=6
Req 5 - completionInfo96ms (± 6.11%)101ms (± 2.06%)~98ms103msp=0.371 n=6
CompilerTSServer - node (v14.15.1, x64)
Req 1 - updateOpen2,831ms (± 0.59%)2,825ms (± 0.59%)~2,804ms2,847msp=0.630 n=6
Req 2 - geterr4,684ms (± 2.62%)4,716ms (± 2.42%)~4,560ms4,807msp=0.810 n=6
Req 3 - references389ms (± 6.97%)379ms (± 5.51%)~368ms421msp=0.466 n=6
Req 4 - navto289ms (± 1.08%)292ms (± 1.62%)~285ms297msp=0.361 n=6
Req 5 - completionInfo count1,518 (± 0.00%)1,518 (± 0.00%)~1,5181,518p=1.000 n=6
Req 5 - completionInfo80ms (± 9.99%)78ms (± 9.21%)~74ms92msp=0.366 n=6
xstateTSServer - node (v14.15.1, x64)
Req 1 - updateOpen3,458ms (± 0.44%)3,444ms (± 0.42%)~3,421ms3,461msp=0.298 n=6
Req 2 - geterr1,869ms (± 1.26%)1,890ms (± 1.11%)~1,854ms1,917msp=0.149 n=6
Req 3 - references125ms (± 0.60%)125ms (± 1.60%)~123ms128msp=0.676 n=6
Req 4 - navto372ms (± 0.53%)370ms (± 0.33%)~369ms372msp=0.285 n=6
Req 5 - completionInfo count2,861 (± 0.00%)2,861 (± 0.00%)~2,8612,861p=1.000 n=6
Req 5 - completionInfo408ms (± 1.22%)406ms (± 0.90%)~401ms411msp=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)
BenchmarkNameIterations
Current534896
Baselinemain6

Startup

Comparison Report - main..53489
Metricmain53489DeltaBestWorstp-value
tsc-startup - node (v16.17.1, x64)
Execution time141.87ms (± 0.23%)141.27ms (± 0.20%)-0.60ms (- 0.43%)140.63ms146.58msp=0.000 n=600
tsserver-startup - node (v16.17.1, x64)
Execution time229.11ms (± 0.47%)227.22ms (± 0.41%)-1.89ms (- 0.83%)224.85ms233.56msp=0.000 n=600
tsserverlibrary-startup - node (v16.17.1, x64)
Execution time230.78ms (± 0.38%)227.97ms (± 0.20%)-2.81ms (- 1.22%)226.74ms232.94msp=0.000 n=600
typescript-startup - node (v16.17.1, x64)
Execution time210.94ms (± 0.35%)209.10ms (± 0.23%)-1.85ms (- 0.88%)207.82ms216.36msp=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)
BenchmarkNameIterations
Current534896
Baselinemain6

Developer Information:

Download Benchmark

@typescript-bot

Copy link
Copy Markdown
Contributor

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

@typescript-bot

Copy link
Copy Markdown
Contributor

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

Everything looks good!

@ericbf

Eric Ferreira (ericbf) commented Apr 3, 2023

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

Eric Ferreira (ericbf) commented Apr 3, 2023

Copy link
Copy Markdown
Contributor

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.

@weswigham

Copy link
Copy Markdown
MemberAuthor

TypeScript Bot (@typescript-bot) pack this

@typescript-bot

TypeScript Bot (typescript-bot) commented Apr 12, 2023

Copy link
Copy Markdown
Contributor

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

@typescript-bot

TypeScript Bot (typescript-bot) commented Apr 12, 2023

Copy link
Copy Markdown
Contributor

Hey Wesley Wigham (@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/pr-build@5.1.0-pr-53489-15".;

@weswigham

Copy link
Copy Markdown
MemberAuthor

Andrew Branch (@andrewbranch)Anders Hejlsberg (@ahejlsberg) I'm pinging more people for a second review :)

@DanielRosenwasser

Copy link
Copy Markdown
Member

@typescript-bot

TypeScript Bot (typescript-bot) commented Apr 15, 2023

Copy link
Copy Markdown
Contributor

Heya Daniel Rosenwasser (@DanielRosenwasser), 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

TypeScript Bot (typescript-bot) commented Apr 15, 2023

Copy link
Copy Markdown
Contributor

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

Update: The results are in!

@typescript-bot

TypeScript Bot (typescript-bot) commented Apr 15, 2023

Copy link
Copy Markdown
Contributor

Heya Daniel Rosenwasser (@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

TypeScript Bot (typescript-bot) commented Apr 15, 2023

Copy link
Copy Markdown
Contributor

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

@typescript-bot

TypeScript Bot (typescript-bot) commented Apr 15, 2023

Copy link
Copy Markdown
Contributor

Heya Daniel Rosenwasser (@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

TypeScript Bot (typescript-bot) commented Apr 15, 2023

Copy link
Copy Markdown
Contributor

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

@typescript-bot

TypeScript Bot (typescript-bot) commented Apr 15, 2023

Copy link
Copy Markdown
Contributor

Heya Daniel Rosenwasser (@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

TypeScript Bot (typescript-bot) commented Apr 15, 2023

Copy link
Copy Markdown
Contributor

Hey Daniel Rosenwasser (@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/pr-build@5.1.0-pr-53489-26".;

@typescript-bot

Copy link
Copy Markdown
Contributor

Daniel Rosenwasser (@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
Copy Markdown
Contributor

Daniel Rosenwasser (@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
Copy Markdown
Contributor

Daniel Rosenwasser (@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
Copy Markdown
Contributor

Daniel Rosenwasser (@DanielRosenwasser)
The results of the perf run you requested are in!

Here they are:

Compiler

Comparison Report - main..53489
Metricmain53489DeltaBestWorstp-value
Angular - node (v18.10.0, x64)
Memory used365,213k (± 0.01%)365,217k (± 0.01%)~365,173k365,281kp=0.810 n=6
Parse Time3.35s (± 0.57%)3.35s (± 0.70%)~3.31s3.37sp=0.934 n=6
Bind Time1.11s (± 1.47%)1.13s (± 0.93%)~1.11s1.14sp=0.250 n=6
Check Time8.72s (± 0.29%)8.70s (± 0.50%)~8.64s8.75sp=0.258 n=6
Emit Time7.44s (± 0.25%)7.48s (± 0.28%)+0.04s (+ 0.52%)7.46s7.51sp=0.007 n=6
Total Time20.63s (± 0.21%)20.65s (± 0.35%)~20.54s20.74sp=0.573 n=6
Compiler-Unions - node (v18.10.0, x64)
Memory used191,342k (± 0.53%)190,957k (± 0.02%)~190,916k191,002kp=0.261 n=6
Parse Time1.49s (± 0.27%)1.50s (± 0.60%)+0.01s (+ 0.78%)1.49s1.51sp=0.025 n=6
Bind Time0.77s (± 0.53%)0.77s (± 0.98%)~0.76s0.78sp=1.000 n=6
Check Time9.52s (± 0.57%)9.55s (± 0.37%)~9.51s9.59sp=0.334 n=6
Emit Time2.73s (± 1.24%)2.74s (± 1.12%)~2.71s2.79sp=0.565 n=6
Total Time14.50s (± 0.49%)14.55s (± 0.32%)~14.49s14.61sp=0.199 n=6
Monaco - node (v18.10.0, x64)
Memory used346,495k (± 0.01%)346,516k (± 0.01%)~346,488k346,562kp=0.173 n=6
Parse Time2.59s (± 0.73%)2.57s (± 1.76%)~2.53s2.63sp=0.629 n=6
Bind Time1.01s (± 0.63%)1.00s (± 0.41%)-0.01s (- 0.83%)1.00s1.01sp=0.033 n=6
Check Time7.13s (± 0.49%)7.12s (± 0.30%)~7.09s7.15sp=0.334 n=6
Emit Time4.24s (± 0.55%)4.26s (± 0.95%)~4.23s4.34sp=0.255 n=6
Total Time14.97s (± 0.44%)14.96s (± 0.42%)~14.90s15.04sp=1.000 n=6
TFS - node (v18.10.0, x64)
Memory used300,717k (± 0.01%)300,703k (± 0.01%)~300,686k300,743kp=0.336 n=6
Parse Time2.04s (± 1.34%)2.06s (± 1.11%)~2.04s2.10sp=0.295 n=6
Bind Time1.14s (± 1.24%)1.14s (± 0.55%)~1.13s1.15sp=1.000 n=6
Check Time6.53s (± 0.51%)6.53s (± 0.34%)~6.49s6.55sp=0.808 n=6
Emit Time3.86s (± 0.81%)3.86s (± 1.20%)~3.81s3.92sp=0.871 n=6
Total Time13.58s (± 0.51%)13.59s (± 0.34%)~13.53s13.66sp=0.572 n=6
material-ui - node (v18.10.0, x64)
Memory used481,862k (± 0.01%)481,833k (± 0.00%)~481,810k481,856kp=0.127 n=6
Parse Time3.03s (± 0.70%)3.03s (± 0.54%)~3.01s3.05sp=0.745 n=6
Bind Time0.91s (± 2.56%)0.91s (± 1.61%)~0.90s0.94sp=0.796 n=6
Check Time16.77s (± 0.46%)16.82s (± 0.58%)~16.72s16.98sp=0.378 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time20.72s (± 0.29%)20.77s (± 0.50%)~20.66s20.94sp=0.521 n=6
xstate - node (v18.10.0, x64)
Memory used561,801k (± 0.02%)561,819k (± 0.03%)~561,645k562,132kp=0.936 n=6
Parse Time3.81s (± 0.91%)3.82s (± 0.52%)~3.80s3.85sp=0.418 n=6
Bind Time1.65s (± 0.71%)1.65s (± 0.46%)~1.64s1.66sp=0.933 n=6
Check Time2.80s (± 0.73%)2.80s (± 1.07%)~2.77s2.84sp=0.936 n=6
Emit Time0.08s (± 0.00%)0.08s (± 0.00%)~0.08s0.08sp=1.000 n=6
Total Time8.34s (± 0.65%)8.36s (± 0.44%)~8.31s8.41sp=0.688 n=6
Angular - node (v16.17.1, x64)
Memory used364,602k (± 0.00%)364,606k (± 0.01%)~364,582k364,636kp=0.688 n=6
Parse Time3.54s (± 0.71%)3.54s (± 0.79%)~3.50s3.57sp=0.807 n=6
Bind Time1.18s (± 1.39%)1.18s (± 0.76%)~1.17s1.19sp=0.560 n=6
Check Time9.50s (± 0.32%)9.47s (± 0.29%)~9.44s9.51sp=0.225 n=6
Emit Time7.92s (± 0.68%)7.95s (± 0.40%)~7.91s7.99sp=0.125 n=6
Total Time22.14s (± 0.26%)22.15s (± 0.25%)~22.05s22.19sp=0.809 n=6
Compiler-Unions - node (v16.17.1, x64)
Memory used193,129k (± 0.69%)192,613k (± 0.03%)~192,537k192,666kp=0.810 n=6
Parse Time1.59s (± 0.51%)1.57s (± 1.86%)~1.53s1.60sp=0.532 n=6
Bind Time0.82s (± 0.50%)0.82s (± 0.66%)~0.82s0.83sp=0.282 n=6
Check Time10.22s (± 0.44%)10.24s (± 0.64%)~10.12s10.31sp=0.227 n=6
Emit Time2.99s (± 0.72%)3.00s (± 0.93%)~2.97s3.05sp=0.290 n=6
Total Time15.61s (± 0.31%)15.64s (± 0.44%)~15.53s15.72sp=0.336 n=6
Monaco - node (v16.17.1, x64)
Memory used345,786k (± 0.01%)345,792k (± 0.01%)~345,769k345,821kp=0.521 n=6
Parse Time2.72s (± 0.19%)2.72s (± 0.43%)~2.71s2.74sp=0.929 n=6
Bind Time1.08s (± 0.48%)1.08s (± 0.70%)~1.07s1.09sp=0.784 n=6
Check Time7.85s (± 0.31%)7.83s (± 0.50%)~7.80s7.90sp=0.107 n=6
Emit Time4.48s (± 0.74%)4.48s (± 0.68%)~4.44s4.52sp=0.936 n=6
Total Time16.14s (± 0.30%)16.11s (± 0.44%)~16.06s16.25sp=0.260 n=6
TFS - node (v16.17.1, x64)
Memory used300,051k (± 0.01%)300,063k (± 0.00%)~300,049k300,082kp=0.748 n=6
Parse Time2.16s (± 0.49%)2.16s (± 0.41%)~2.15s2.17sp=0.452 n=6
Bind Time1.24s (± 0.85%)1.23s (± 1.22%)~1.21s1.25sp=1.000 n=6
Check Time7.19s (± 0.43%)7.16s (± 0.16%)~7.15s7.18sp=0.084 n=6
Emit Time4.34s (± 0.51%)4.33s (± 0.60%)~4.29s4.36sp=0.686 n=6
Total Time14.91s (± 0.31%)14.89s (± 0.32%)~14.82s14.95sp=0.377 n=6
material-ui - node (v16.17.1, x64)
Memory used481,178k (± 0.01%)481,213k (± 0.02%)~481,093k481,298kp=0.689 n=6
Parse Time3.24s (± 0.41%)3.24s (± 0.42%)~3.23s3.27sp=0.868 n=6
Bind Time0.95s (± 0.57%)0.95s (± 0.54%)-0.01s (- 0.87%)0.94s0.95sp=0.038 n=6
Check Time17.80s (± 0.43%)17.84s (± 0.26%)~17.76s17.88sp=0.261 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time22.00s (± 0.38%)22.03s (± 0.19%)~21.97s22.07sp=0.297 n=6
xstate - node (v16.17.1, x64)
Memory used559,536k (± 0.03%)559,468k (± 0.03%)~559,336k559,705kp=0.574 n=6
Parse Time3.99s (± 0.25%)4.00s (± 0.43%)~3.98s4.02sp=0.154 n=6
Bind Time1.75s (± 0.43%)1.75s (± 0.23%)~1.75s1.76sp=0.389 n=6
Check Time3.02s (± 0.34%)3.01s (± 0.18%)-0.01s (- 0.39%)3.00s3.01sp=0.047 n=6
Emit Time0.09s (± 0.00%)0.09s (± 0.00%)~0.09s0.09sp=1.000 n=6
Total Time8.84s (± 0.23%)8.85s (± 0.20%)~8.83s8.88sp=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)
BenchmarkNameIterations
Current534896
Baselinemain6

TSServer

Comparison Report - main..53489
Metricmain53489DeltaBestWorstp-value
Compiler-UnionsTSServer - node (v18.10.0, x64)
Req 1 - updateOpen2,393ms (± 0.32%)2,407ms (± 0.77%)~2,386ms2,438msp=0.149 n=6
Req 2 - geterr5,605ms (± 0.83%)5,587ms (± 1.66%)~5,412ms5,662msp=0.936 n=6
Req 3 - references339ms (± 0.48%)340ms (± 1.14%)~338ms348msp=0.511 n=6
Req 4 - navto284ms (± 0.49%)286ms (± 1.00%)~283ms291msp=0.101 n=6
Req 5 - completionInfo count1,356 (± 0.00%)1,356 (± 0.00%)~1,3561,356p=1.000 n=6
Req 5 - completionInfo84ms (± 0.75%)82ms (± 8.61%)~68ms88msp=1.000 n=6
CompilerTSServer - node (v18.10.0, x64)
Req 1 - updateOpen2,504ms (± 1.25%)2,517ms (± 1.47%)~2,471ms2,555msp=0.471 n=6
Req 2 - geterr4,214ms (± 0.42%)4,218ms (± 1.30%)~4,111ms4,258msp=0.297 n=6
Req 3 - references343ms (± 0.39%)351ms (± 5.40%)~341ms390msp=0.249 n=6
Req 4 - navto290ms (± 1.44%)288ms (± 0.83%)~283ms289msp=0.720 n=6
Req 5 - completionInfo count1,518 (± 0.00%)1,518 (± 0.00%)~1,5181,518p=1.000 n=6
Req 5 - completionInfo64ms (± 4.56%)65ms (± 5.99%)~62ms70msp=0.933 n=6
xstateTSServer - node (v18.10.0, x64)
Req 1 - updateOpen3,025ms (± 0.38%)3,018ms (± 0.19%)~3,009ms3,025msp=0.295 n=6
Req 2 - geterr1,597ms (± 0.76%)1,605ms (± 0.66%)~1,598ms1,626msp=0.572 n=6
Req 3 - references108ms (± 4.05%)108ms (± 2.68%)~105ms113msp=0.622 n=6
Req 4 - navto364ms (± 0.33%)362ms (± 0.48%)~360ms364msp=0.166 n=6
Req 5 - completionInfo count2,862 (± 0.00%)2,862 (± 0.00%)~2,8622,862p=1.000 n=6
Req 5 - completionInfo374ms (± 1.34%)377ms (± 2.25%)~362ms386msp=0.261 n=6
Compiler-UnionsTSServer - node (v16.17.1, x64)
Req 1 - updateOpen2,522ms (± 0.59%)2,532ms (± 0.69%)~2,503ms2,554msp=0.298 n=6
Req 2 - geterr6,016ms (± 0.58%)6,025ms (± 0.78%)~5,978ms6,107msp=1.000 n=6
Req 3 - references352ms (± 0.63%)353ms (± 0.74%)~349ms357msp=0.739 n=6
Req 4 - navto287ms (± 1.73%)285ms (± 1.69%)~280ms293msp=0.807 n=6
Req 5 - completionInfo count1,356 (± 0.00%)1,356 (± 0.00%)~1,3561,356p=1.000 n=6
Req 5 - completionInfo90ms (± 5.22%)89ms (± 5.56%)~80ms92msp=0.865 n=6
CompilerTSServer - node (v16.17.1, x64)
Req 1 - updateOpen2,661ms (± 1.15%)2,682ms (± 0.89%)~2,644ms2,713msp=0.199 n=6
Req 2 - geterr4,620ms (± 0.51%)4,631ms (± 0.38%)~4,615ms4,654msp=0.470 n=6
Req 3 - references358ms (± 0.51%)360ms (± 0.49%)~359ms363msp=0.088 n=6
Req 4 - navto281ms (± 0.84%)282ms (± 1.04%)~278ms284msp=0.456 n=6
Req 5 - completionInfo count1,518 (± 0.00%)1,518 (± 0.00%)~1,5181,518p=1.000 n=6
Req 5 - completionInfo68ms (± 1.24%)68ms (± 1.72%)~66ms69msp=0.555 n=6
xstateTSServer - node (v16.17.1, x64)
Req 1 - updateOpen3,176ms (± 0.28%)3,182ms (± 0.32%)~3,172ms3,197msp=0.378 n=6
Req 2 - geterr1,745ms (± 0.86%)1,749ms (± 0.79%)~1,737ms1,770msp=0.748 n=6
Req 3 - references120ms (± 1.23%)120ms (± 1.39%)~118ms123msp=0.934 n=6
Req 4 - navto342ms (± 1.04%)341ms (± 0.34%)~339ms342msp=0.868 n=6
Req 5 - completionInfo count2,862 (± 0.00%)2,862 (± 0.00%)~2,8622,862p=1.000 n=6
Req 5 - completionInfo390ms (± 0.78%)394ms (± 0.89%)~389ms398msp=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)
BenchmarkNameIterations
Current534896
Baselinemain6

Startup

Comparison Report - main..53489
Metricmain53489DeltaBestWorstp-value
tsc-startup - node (v16.17.1, x64)
Execution time141.84ms (± 0.16%)142.14ms (± 0.20%)+0.29ms (+ 0.21%)141.48ms147.46msp=0.000 n=600
tsserver-startup - node (v16.17.1, x64)
Execution time220.14ms (± 0.16%)220.89ms (± 0.19%)+0.75ms (+ 0.34%)219.95ms230.61msp=0.000 n=600
tsserverlibrary-startup - node (v16.17.1, x64)
Execution time221.64ms (± 0.16%)222.09ms (± 0.16%)+0.45ms (+ 0.20%)221.29ms228.00msp=0.000 n=600
typescript-startup - node (v16.17.1, x64)
Execution time203.43ms (± 0.15%)203.86ms (± 0.16%)+0.43ms (+ 0.21%)203.10ms209.16msp=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)
BenchmarkNameIterations
Current534896
Baselinemain6

Developer Information:

Download Benchmark

@typescript-bot

Copy link
Copy Markdown
Contributor

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

@typescript-bot

Copy link
Copy Markdown
Contributor

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

Everything looks good!

@ialexryan

Copy link
Copy Markdown
Contributor

Hurray! Thank you so much Wesley Wigham (@weswigham) 🎉 🙇🏻

@thorn0

Copy link
Copy Markdown

Seems to fix #42646

@craigphicks

Copy link
Copy Markdown

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

Eric Ferreira (ericbf) commented Sep 18, 2023

Copy link
Copy Markdown
Contributor

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 freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Author: TeamFor Uncommitted BugPR 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

11 participants

@weswigham@typescript-bot@ericbf@RyanCavanaugh@DanielRosenwasser@ialexryan@thorn0@craigphicks@andrewbranch@gabritto@sandersn