Skip to content

Consider index signatures as optional properties in contextual type discrimination - #54596

Merged
Gabriela Araujo Britto (gabritto) merged 7 commits into
mainfrom
gabritto/issue54498
Jun 13, 2023
Merged

Consider index signatures as optional properties in contextual type discrimination#54596
Gabriela Araujo Britto (gabritto) merged 7 commits into
mainfrom
gabritto/issue54498

Conversation

@gabritto

Copy link
Copy Markdown
Member

Fixes#54498.
The fix is suggested and described by Nebojša Cvetković (@nebkat) in this comment: #54498 (comment).

When we try to discriminate a contextual type, we consider the omission of a property to be a factor to discriminate in discriminateTypeByDiscriminableItems's implementation, but then during that process, when looking up a property in one of the candidate types, we would not consider matching index signatures and therefore we would discard the type with the index signature. Now, when looking up a property in one of the candidate types, we also consider matching on index signatures.

Comment threadsrc/compiler/checker.ts Outdated
const filtered = contains(include, Ternary.False) ? getUnionType(types.filter((_, i) => include[i])) : target;
return filtered.flags & TypeFlags.Never ? target : filtered;

function getTypeOfPropertyOrOptionalIndexSignature(type: Type, name: __String): Type | undefined {

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I feel like this function might already exist, but I couldn't find it.

@DanielRosenwasserDaniel Rosenwasser (DanielRosenwasser)Jun 12, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There's getTypeOfPropertyOrIndexSignature (used by narrowTypeByDiscriminant!). Consider replacing that function and making it take a parameter on whether to add optionality for index signatures.

@gabritto

Copy link
Copy Markdown
MemberAuthor

@typescript-bot

TypeScript Bot (typescript-bot) commented Jun 10, 2023

Copy link
Copy Markdown
Contributor

Heya Gabriela Araujo Britto (@gabritto), I've started to run the parallelized Definitely Typed test suite on this PR at c66c0d1. You can monitor the build here.

Update: The results are in!

@typescript-bot

TypeScript Bot (typescript-bot) commented Jun 10, 2023

Copy link
Copy Markdown
Contributor

Heya Gabriela Araujo Britto (@gabritto), I've started to run the diff-based user code test suite on this PR at c66c0d1. You can monitor the build here.

Update: The results are in!

@typescript-bot

TypeScript Bot (typescript-bot) commented Jun 10, 2023

Copy link
Copy Markdown
Contributor

Heya Gabriela Araujo Britto (@gabritto), I've started to run the extended test suite on this PR at c66c0d1. You can monitor the build here.

@typescript-bot

TypeScript Bot (typescript-bot) commented Jun 10, 2023

Copy link
Copy Markdown
Contributor

Heya Gabriela Araujo Britto (@gabritto), I've started to run the perf test suite on this PR at c66c0d1. You can monitor the build here.

Update: The results are in!

@typescript-bot

TypeScript Bot (typescript-bot) commented Jun 10, 2023

Copy link
Copy Markdown
Contributor

Heya Gabriela Araujo Britto (@gabritto), I've started to run the diff-based top-repos suite on this PR at c66c0d1. You can monitor the build here.

Update: The results are in!

@typescript-bot

Copy link
Copy Markdown
Contributor

Gabriela Araujo Britto (@gabritto) Here are the results of running the user test suite comparing main and refs/pull/54596/merge:

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Unknown failure"
  • 1 instance of "Package install failed"

Otherwise...

Something interesting changed - please have a look.

Details

rxjs-src

/mnt/ts_downloads/rxjs-src/build.sh

  • [NEW] error TS2428: All declarations of 'WeakMap' must have identical type parameters.
    • /home/vsts/work/1/s/typescript-54596/lib/lib.es2015.collection.d.ts(63,11)
    • /home/vsts/work/1/s/typescript-54596/lib/lib.es2015.iterable.d.ts(162,11)
    • /home/vsts/work/1/s/typescript-54596/lib/lib.es2015.symbol.wellknown.d.ts(140,11)
    • /home/vsts/work/1/s/typescript-54596/lib/lib.es2015.collection.d.ts(63,11)
    • /home/vsts/work/1/s/typescript-54596/lib/lib.es2015.iterable.d.ts(162,11)
    • /home/vsts/work/1/s/typescript-54596/lib/lib.es2015.symbol.wellknown.d.ts(140,11)
    • /home/vsts/work/1/s/typescript-54596/lib/lib.es2015.collection.d.ts(63,11)
    • /home/vsts/work/1/s/typescript-54596/lib/lib.es2015.iterable.d.ts(162,11)
    • /home/vsts/work/1/s/typescript-54596/lib/lib.es2015.symbol.wellknown.d.ts(140,11)
    • /home/vsts/work/1/s/typescript-54596/lib/lib.es2015.collection.d.ts(63,11)
    • /home/vsts/work/1/s/typescript-54596/lib/lib.es2015.iterable.d.ts(162,11)
    • /home/vsts/work/1/s/typescript-54596/lib/lib.es2015.symbol.wellknown.d.ts(140,11)
    • /home/vsts/work/1/s/typescript-54596/lib/lib.es2015.collection.d.ts(63,11)
    • /home/vsts/work/1/s/typescript-54596/lib/lib.es2015.iterable.d.ts(162,11)
    • /home/vsts/work/1/s/typescript-54596/lib/lib.es2015.symbol.wellknown.d.ts(140,11)
  • [MISSING] error TS2428: All declarations of 'WeakMap' must have identical type parameters.
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.collection.d.ts(63,11)
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.iterable.d.ts(162,11)
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.symbol.wellknown.d.ts(140,11)
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.collection.d.ts(63,11)
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.iterable.d.ts(162,11)
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.symbol.wellknown.d.ts(140,11)
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.collection.d.ts(63,11)
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.iterable.d.ts(162,11)
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.symbol.wellknown.d.ts(140,11)
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.collection.d.ts(63,11)
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.iterable.d.ts(162,11)
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.symbol.wellknown.d.ts(140,11)
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.collection.d.ts(63,11)
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.iterable.d.ts(162,11)
    • /home/vsts/work/1/s/typescript-main/lib/lib.es2015.symbol.wellknown.d.ts(140,11)

@typescript-bot

Copy link
Copy Markdown
Contributor

Gabriela Araujo Britto (@gabritto)
The results of the perf run you requested are in!

Here they are:

Compiler

Comparison Report - main..54596
Metricmain54596DeltaBestWorstp-value
Angular - node (v18.10.0, x64)
Memory used366,149k (± 0.01%)366,155k (± 0.01%)~366,131k366,186kp=1.000 n=6
Parse Time3.42s (± 0.78%)3.41s (± 0.71%)~3.39s3.45sp=0.870 n=6
Bind Time1.12s (± 0.36%)1.11s (± 1.23%)~1.10s1.13sp=0.490 n=6
Check Time8.76s (± 0.51%)8.77s (± 0.43%)~8.72s8.80sp=0.683 n=6
Emit Time7.45s (± 1.15%)7.45s (± 0.51%)~7.42s7.52sp=0.569 n=6
Total Time20.74s (± 0.56%)20.75s (± 0.32%)~20.67s20.86sp=0.689 n=6
Compiler-Unions - node (v18.10.0, x64)
Memory used192,156k (± 1.24%)193,997k (± 1.60%)~191,151k196,946kp=0.810 n=6
Parse Time1.51s (± 0.91%)1.51s (± 1.29%)~1.48s1.53sp=0.804 n=6
Bind Time0.77s (± 0.53%)0.77s (± 0.53%)~0.76s0.77sp=0.218 n=6
Check Time9.47s (± 0.43%)9.48s (± 0.52%)~9.43s9.55sp=0.687 n=6
Emit Time2.75s (± 1.16%)2.74s (± 1.69%)~2.68s2.81sp=0.629 n=6
Total Time14.50s (± 0.39%)14.50s (± 0.73%)~14.38s14.64sp=1.000 n=6
Monaco - node (v18.10.0, x64)
Memory used346,626k (± 0.01%)346,620k (± 0.01%)~346,567k346,677kp=0.936 n=6
Parse Time2.59s (± 0.57%)2.59s (± 1.24%)~2.56s2.64sp=0.808 n=6
Bind Time1.01s (± 0.81%)1.01s (± 1.02%)~0.99s1.02sp=0.932 n=6
Check Time7.13s (± 0.56%)7.14s (± 0.36%)~7.11s7.17sp=0.809 n=6
Emit Time4.24s (± 0.65%)4.27s (± 0.87%)~4.23s4.33sp=0.101 n=6
Total Time14.98s (± 0.41%)15.01s (± 0.42%)~14.93s15.12sp=0.376 n=6
TFS - node (v18.10.0, x64)
Memory used300,628k (± 0.01%)300,645k (± 0.01%)~300,624k300,683kp=0.199 n=6
Parse Time2.05s (± 1.00%)2.05s (± 0.69%)~2.03s2.07sp=0.739 n=6
Bind Time1.14s (± 0.00%)1.14s (± 1.03%)~1.12s1.15sp=1.000 n=6
Check Time6.60s (± 0.45%)6.64s (± 0.46%)+0.04s (+ 0.63%)6.60s6.67sp=0.045 n=6
Emit Time3.85s (± 0.83%)3.87s (± 0.70%)~3.83s3.90sp=0.294 n=6
Total Time13.65s (± 0.32%)13.70s (± 0.38%)~13.62s13.76sp=0.076 n=6
material-ui - node (v18.10.0, x64)
Memory used481,761k (± 0.01%)481,766k (± 0.01%)~481,723k481,800kp=0.873 n=6
Parse Time3.10s (± 0.70%)3.12s (± 0.74%)~3.08s3.15sp=0.329 n=6
Bind Time0.91s (± 0.82%)0.91s (± 0.45%)~0.91s0.92sp=1.000 n=6
Check Time16.82s (± 0.56%)16.93s (± 1.08%)~16.75s17.20sp=0.470 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time20.84s (± 0.45%)20.96s (± 0.88%)~20.78s21.22sp=0.470 n=6
xstate - node (v18.10.0, x64)
Memory used563,211k (± 0.02%)563,053k (± 0.02%)~562,911k563,266kp=0.066 n=6
Parse Time3.81s (± 0.52%)3.82s (± 0.69%)~3.79s3.86sp=0.572 n=6
Bind Time1.62s (± 0.55%)1.63s (± 0.63%)~1.62s1.64sp=0.345 n=6
Check Time2.82s (± 0.73%)2.82s (± 0.92%)~2.79s2.86sp=0.872 n=6
Emit Time0.08s (± 0.00%)0.08s (± 0.00%)~0.08s0.08sp=1.000 n=6
Total Time8.32s (± 0.40%)8.35s (± 0.46%)~8.30s8.39sp=0.418 n=6
Angular - node (v16.17.1, x64)
Memory used365,545k (± 0.01%)365,533k (± 0.01%)~365,467k365,582kp=0.748 n=6
Parse Time3.55s (± 0.23%)3.57s (± 0.52%)~3.53s3.58sp=0.061 n=6
Bind Time1.18s (± 0.76%)1.18s (± 0.64%)~1.17s1.19sp=0.798 n=6
Check Time9.57s (± 0.22%)9.60s (± 0.31%)~9.57s9.65sp=0.103 n=6
Emit Time7.89s (± 0.30%)7.94s (± 1.00%)~7.81s8.06sp=0.065 n=6
Total Time22.20s (± 0.19%)22.28s (± 0.46%)~22.09s22.39sp=0.077 n=6
Compiler-Unions - node (v16.17.1, x64)
Memory used192,898k (± 0.02%)192,970k (± 0.03%)+72k (+ 0.04%)192,904k193,045kp=0.031 n=6
Parse Time1.60s (± 0.65%)1.59s (± 1.62%)~1.56s1.63sp=1.000 n=6
Bind Time0.83s (± 0.62%)0.83s (± 0.49%)~0.82s0.83sp=0.595 n=6
Check Time10.17s (± 0.75%)10.21s (± 0.71%)~10.13s10.31sp=0.748 n=6
Emit Time3.00s (± 0.93%)3.01s (± 0.98%)~2.96s3.04sp=0.809 n=6
Total Time15.60s (± 0.58%)15.64s (± 0.59%)~15.53s15.75sp=0.575 n=6
Monaco - node (v16.17.1, x64)
Memory used345,892k (± 0.00%)345,895k (± 0.00%)~345,874k345,916kp=0.689 n=6
Parse Time2.71s (± 0.20%)2.73s (± 0.76%)~2.70s2.76sp=0.360 n=6
Bind Time1.08s (± 0.70%)1.09s (± 1.07%)~1.08s1.11sp=0.383 n=6
Check Time7.83s (± 0.31%)7.84s (± 0.39%)~7.81s7.88sp=0.936 n=6
Emit Time4.43s (± 0.23%)4.49s (± 0.42%)+0.06s (+ 1.28%)4.47s4.52sp=0.005 n=6
Total Time16.06s (± 0.15%)16.15s (± 0.36%)+0.09s (+ 0.56%)16.07s16.21sp=0.010 n=6
TFS - node (v16.17.1, x64)
Memory used299,974k (± 0.01%)299,974k (± 0.01%)~299,942k299,990kp=0.936 n=6
Parse Time2.15s (± 0.54%)2.16s (± 0.65%)~2.14s2.18sp=0.357 n=6
Bind Time1.24s (± 1.35%)1.24s (± 0.98%)~1.22s1.25sp=0.742 n=6
Check Time7.26s (± 0.47%)7.31s (± 0.36%)+0.05s (+ 0.71%)7.28s7.35sp=0.036 n=6
Emit Time4.36s (± 1.01%)4.35s (± 0.96%)~4.28s4.40sp=0.573 n=6
Total Time15.02s (± 0.55%)15.05s (± 0.26%)~15.00s15.11sp=0.521 n=6
material-ui - node (v16.17.1, x64)
Memory used481,041k (± 0.01%)480,994k (± 0.01%)-47k (- 0.01%)480,965k481,024kp=0.031 n=6
Parse Time3.25s (± 0.41%)3.27s (± 0.25%)+0.02s (+ 0.56%)3.26s3.28sp=0.045 n=6
Bind Time0.94s (± 0.67%)0.94s (± 1.09%)~0.93s0.96sp=0.654 n=6
Check Time17.96s (± 0.77%)17.97s (± 0.67%)~17.80s18.10sp=0.936 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time22.14s (± 0.70%)22.19s (± 0.58%)~22.00s22.32sp=0.575 n=6
xstate - node (v16.17.1, x64)
Memory used560,679k (± 0.03%)560,682k (± 0.01%)~560,594k560,789kp=0.471 n=6
Parse Time3.99s (± 0.29%)4.00s (± 0.34%)~3.99s4.02sp=0.073 n=6
Bind Time1.75s (± 0.31%)1.76s (± 1.18%)~1.72s1.78sp=0.866 n=6
Check Time3.06s (± 0.48%)3.05s (± 0.44%)~3.04s3.07sp=0.511 n=6
Emit Time0.09s (± 0.00%)0.09s (± 0.00%)~0.09s0.09sp=1.000 n=6
Total Time8.89s (± 0.23%)8.91s (± 0.43%)~8.86s8.95sp=0.627 n=6
Angular - node (v14.21.3, x64)
Memory used359,532k (± 0.01%)359,542k (± 0.01%)~359,518k359,576kp=0.423 n=6
Parse Time3.65s (± 0.33%)3.68s (± 0.53%)+0.03s (+ 0.78%)3.66s3.71sp=0.010 n=6
Bind Time1.21s (± 0.45%)1.22s (± 0.52%)~1.21s1.23sp=0.201 n=6
Check Time10.00s (± 0.69%)10.04s (± 0.35%)~9.98s10.09sp=0.127 n=6
Emit Time8.32s (± 0.84%)8.35s (± 0.83%)~8.25s8.43sp=0.378 n=6
Total Time23.19s (± 0.53%)23.29s (± 0.44%)~23.17s23.44sp=0.128 n=6
Compiler-Unions - node (v14.21.3, x64)
Memory used188,302k (± 0.01%)188,274k (± 0.02%)~188,230k188,344kp=0.078 n=6
Parse Time1.60s (± 0.34%)1.62s (± 0.76%)~1.59s1.62sp=0.053 n=6
Bind Time0.84s (± 0.65%)0.85s (± 0.89%)~0.84s0.86sp=0.476 n=6
Check Time10.29s (± 0.67%)10.34s (± 0.74%)~10.20s10.41sp=0.336 n=6
Emit Time3.13s (± 0.79%)3.13s (± 0.74%)~3.10s3.16sp=1.000 n=6
Total Time15.87s (± 0.55%)15.93s (± 0.60%)~15.78s16.05sp=0.297 n=6
Monaco - node (v14.21.3, x64)
Memory used341,025k (± 0.01%)341,029k (± 0.01%)~340,961k341,062kp=0.809 n=6
Parse Time2.80s (± 0.49%)2.81s (± 0.37%)~2.80s2.83sp=0.241 n=6
Bind Time1.11s (± 0.37%)1.11s (± 0.37%)~1.11s1.12sp=0.218 n=6
Check Time8.16s (± 0.41%)8.24s (± 0.84%)+0.08s (+ 0.96%)8.16s8.34sp=0.037 n=6
Emit Time4.68s (± 0.80%)4.71s (± 0.70%)~4.66s4.75sp=0.196 n=6
Total Time16.75s (± 0.32%)16.87s (± 0.46%)+0.12s (+ 0.72%)16.80s16.97sp=0.020 n=6
TFS - node (v14.21.3, x64)
Memory used295,143k (± 0.00%)295,150k (± 0.00%)~295,145k295,159kp=0.077 n=6
Parse Time2.39s (± 0.98%)2.41s (± 0.81%)~2.39s2.44sp=0.123 n=6
Bind Time1.07s (± 2.18%)1.07s (± 0.51%)~1.06s1.07sp=0.859 n=6
Check Time7.58s (± 0.50%)7.59s (± 0.49%)~7.54s7.65sp=0.572 n=6
Emit Time4.34s (± 0.47%)4.32s (± 0.81%)~4.26s4.36sp=0.373 n=6
Total Time15.38s (± 0.40%)15.39s (± 0.43%)~15.29s15.49sp=0.810 n=6
material-ui - node (v14.21.3, x64)
Memory used476,575k (± 0.00%)476,579k (± 0.01%)~476,537k476,613kp=0.689 n=6
Parse Time3.33s (± 0.52%)3.36s (± 0.40%)+0.03s (+ 0.80%)3.34s3.38sp=0.022 n=6
Bind Time1.00s (± 0.75%)1.01s (± 0.75%)~1.00s1.02sp=0.195 n=6
Check Time18.64s (± 0.42%)18.81s (± 0.65%)+0.18s (+ 0.95%)18.64s18.96sp=0.031 n=6
Emit Time0.00s (± 0.00%)0.00s (± 0.00%)~0.00s0.00sp=1.000 n=6
Total Time22.97s (± 0.37%)23.18s (± 0.50%)+0.21s (+ 0.90%)23.00s23.33sp=0.008 n=6
xstate - node (v14.21.3, x64)
Memory used549,695k (± 0.00%)549,689k (± 0.00%)~549,670k549,706kp=0.689 n=6
Parse Time4.23s (± 0.41%)4.25s (± 0.38%)~4.24s4.28sp=0.124 n=6
Bind Time1.67s (± 0.31%)1.68s (± 0.82%)~1.66s1.70sp=0.242 n=6
Check Time3.18s (± 0.77%)3.18s (± 0.43%)~3.15s3.19sp=0.366 n=6
Emit Time0.09s (± 0.00%)0.09s (± 0.00%)~0.09s0.09sp=1.000 n=6
Total Time9.16s (± 0.30%)9.20s (± 0.24%)+0.04s (+ 0.38%)9.18s9.23sp=0.017 n=6
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-148-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
Current545966
Baselinemain6

TSServer

Comparison Report - main..54596
Metricmain54596DeltaBestWorstp-value
Compiler-UnionsTSServer - node (v18.10.0, x64)
Req 1 - updateOpen2,541ms (± 0.39%)2,536ms (± 0.19%)~2,526ms2,539msp=0.195 n=6
Req 2 - geterr5,545ms (± 0.72%)5,529ms (± 0.40%)~5,489ms5,547msp=0.229 n=6
Req 3 - references336ms (± 0.93%)338ms (± 0.82%)~334ms341msp=0.333 n=6
Req 4 - navto289ms (± 1.55%)287ms (± 1.35%)~284ms295msp=0.366 n=6
Req 5 - completionInfo count1,356 (± 0.00%)1,356 (± 0.00%)~1,3561,356p=1.000 n=6
Req 5 - completionInfo85ms (± 0.89%)85ms (± 1.24%)~83ms86msp=0.611 n=6
CompilerTSServer - node (v18.10.0, x64)
Req 1 - updateOpen2,648ms (± 0.44%)2,662ms (± 1.34%)~2,643ms2,734msp=0.748 n=6
Req 2 - geterr4,290ms (± 0.49%)4,253ms (± 1.89%)~4,091ms4,299msp=0.629 n=6
Req 3 - references349ms (± 0.24%)348ms (± 0.34%)~346ms349msp=1.000 n=6
Req 4 - navto286ms (± 0.26%)288ms (± 0.57%)~286ms290msp=0.112 n=6
Req 5 - completionInfo count1,518 (± 0.00%)1,518 (± 0.00%)~1,5181,518p=1.000 n=6
Req 5 - completionInfo65ms (± 5.83%)69ms (±11.94%)~61ms84msp=0.624 n=6
xstateTSServer - node (v18.10.0, x64)
Req 1 - updateOpen3,102ms (± 0.59%)3,086ms (± 0.34%)~3,072ms3,100msp=0.128 n=6
Req 2 - geterr1,564ms (± 1.05%)1,572ms (± 0.82%)~1,555ms1,593msp=0.423 n=6
Req 3 - references114ms (± 1.16%)113ms (± 1.04%)~112ms115msp=0.125 n=6
Req 4 - navto359ms (± 0.34%)358ms (± 0.29%)~356ms359msp=0.210 n=6
Req 5 - completionInfo count2,864 (± 0.00%)2,864 (± 0.00%)~2,8642,864p=1.000 n=6
Req 5 - completionInfo375ms (± 2.71%)381ms (± 1.94%)~366ms387msp=0.421 n=6
Compiler-UnionsTSServer - node (v16.17.1, x64)
Req 1 - updateOpen2,676ms (± 0.45%)2,666ms (± 0.76%)~2,647ms2,697msp=0.378 n=6
Req 2 - geterr6,041ms (± 0.50%)6,007ms (± 0.36%)~5,967ms6,029msp=0.173 n=6
Req 3 - references351ms (± 0.75%)351ms (± 0.64%)~349ms355msp=0.935 n=6
Req 4 - navto289ms (± 1.62%)284ms (± 1.03%)~280ms288msp=0.106 n=6
Req 5 - completionInfo count1,356 (± 0.00%)1,356 (± 0.00%)~1,3561,356p=1.000 n=6
Req 5 - completionInfo94ms (± 0.43%)89ms (± 8.41%)🟩-5ms (- 5.68%)74ms93msp=0.006 n=6
CompilerTSServer - node (v16.17.1, x64)
Req 1 - updateOpen2,830ms (± 0.35%)2,830ms (± 0.51%)~2,809ms2,852msp=0.936 n=6
Req 2 - geterr4,667ms (± 0.34%)4,654ms (± 0.33%)~4,625ms4,669msp=0.378 n=6
Req 3 - references364ms (± 0.25%)364ms (± 0.64%)~361ms367msp=0.807 n=6
Req 4 - navto281ms (± 0.78%)281ms (± 0.81%)~279ms285msp=0.683 n=6
Req 5 - completionInfo count1,518 (± 0.00%)1,518 (± 0.00%)~1,5181,518p=1.000 n=6
Req 5 - completionInfo67ms (± 1.21%)67ms (± 1.21%)~66ms68msp=0.787 n=6
xstateTSServer - node (v16.17.1, x64)
Req 1 - updateOpen3,218ms (± 0.45%)3,213ms (± 0.25%)~3,202ms3,221msp=0.573 n=6
Req 2 - geterr1,743ms (± 0.80%)1,745ms (± 0.85%)~1,726ms1,759msp=0.936 n=6
Req 3 - references126ms (± 7.54%)121ms (± 1.10%)~120ms123msp=0.195 n=6
Req 4 - navto340ms (± 0.61%)340ms (± 0.57%)~337ms342msp=0.867 n=6
Req 5 - completionInfo count2,864 (± 0.00%)2,864 (± 0.00%)~2,8642,864p=1.000 n=6
Req 5 - completionInfo412ms (± 1.40%)416ms (± 1.64%)~408ms425msp=0.368 n=6
Compiler-UnionsTSServer - node (v14.21.3, x64)
Req 1 - updateOpen2,793ms (± 0.44%)2,786ms (± 0.40%)~2,772ms2,801msp=0.377 n=6
Req 2 - geterr6,192ms (± 0.53%)6,175ms (± 0.58%)~6,115ms6,209msp=0.520 n=6
Req 3 - references362ms (± 0.79%)363ms (± 0.47%)~361ms365msp=0.558 n=6
Req 4 - navto290ms (± 1.46%)288ms (± 0.36%)~286ms289msp=0.219 n=6
Req 5 - completionInfo count1,356 (± 0.00%)1,356 (± 0.00%)~1,3561,356p=1.000 n=6
Req 5 - completionInfo98ms (± 3.56%)102ms (± 1.62%)~100ms103msp=0.061 n=6
CompilerTSServer - node (v14.21.3, x64)
Req 1 - updateOpen2,952ms (± 0.83%)2,964ms (± 0.52%)~2,946ms2,986msp=0.173 n=6
Req 2 - geterr4,580ms (± 1.57%)4,562ms (± 0.99%)~4,504ms4,618msp=1.000 n=6
Req 3 - references374ms (± 1.13%)372ms (± 1.00%)~367ms377msp=0.629 n=6
Req 4 - navto297ms (± 0.25%)298ms (± 0.46%)~296ms299msp=0.740 n=6
Req 5 - completionInfo count1,518 (± 0.00%)1,518 (± 0.00%)~1,5181,518p=1.000 n=6
Req 5 - completionInfo77ms (± 4.52%)77ms (± 2.51%)~76ms81msp=0.616 n=6
xstateTSServer - node (v14.21.3, x64)
Req 1 - updateOpen3,455ms (± 1.20%)3,453ms (± 1.36%)~3,390ms3,510msp=1.000 n=6
Req 2 - geterr1,832ms (± 0.59%)1,837ms (± 0.56%)~1,821ms1,844msp=0.744 n=6
Req 3 - references149ms (± 7.33%)151ms (± 6.12%)~133ms158msp=0.936 n=6
Req 4 - navto400ms (± 1.08%)403ms (± 0.76%)~399ms407msp=0.257 n=6
Req 5 - completionInfo count2,864 (± 0.00%)2,864 (± 0.00%)~2,8642,864p=1.000 n=6
Req 5 - completionInfo430ms (± 3.70%)429ms (± 2.86%)~412ms445msp=0.810 n=6
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-148-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
Current545966
Baselinemain6

Startup

Comparison Report - main..54596
Metricmain54596DeltaBestWorstp-value
tsc-startup - node (v16.17.1, x64)
Execution time141.33ms (± 0.21%)141.44ms (± 0.21%)+0.11ms (+ 0.08%)140.62ms144.54msp=0.000 n=600
tsserver-startup - node (v16.17.1, x64)
Execution time220.21ms (± 0.21%)220.79ms (± 0.23%)+0.57ms (+ 0.26%)219.28ms225.59msp=0.000 n=600
tsserverlibrary-startup - node (v16.17.1, x64)
Execution time221.62ms (± 0.13%)221.93ms (± 0.17%)+0.30ms (+ 0.14%)220.73ms225.98msp=0.000 n=600
typescript-startup - node (v16.17.1, x64)
Execution time203.52ms (± 0.20%)203.70ms (± 0.18%)+0.18ms (+ 0.09%)202.69ms207.46msp=0.000 n=600
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-148-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
Current545966
Baselinemain6

Developer Information:

Download Benchmark

@typescript-bot

Copy link
Copy Markdown
Contributor

Gabriela Araujo Britto (@gabritto) Here are the results of running the top-repos suite comparing main and refs/pull/54596/merge:

Everything looks good!

@typescript-bot

Copy link
Copy Markdown
Contributor

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

Comment threadsrc/compiler/checker.ts Outdated
@ImRodry

Copy link
Copy Markdown

This didn't land in 5.1.6 right? When is it expected to be released?

@jakebailey

Copy link
Copy Markdown
Member

This is in the 5.2 beta (also noted in the issue's milestone).

@microsoftMicrosoft (microsoft) locked as resolved and limited conversation to collaborators Oct 22, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Author: TeamFor Milestone BugPRs that fix a bug with a specific milestone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

String constant fails to infer type inside nested unions

5 participants

@gabritto@typescript-bot@ImRodry@jakebailey@DanielRosenwasser