Skip to content

Conversation

@akaltar
Copy link

@akaltar akaltar commented Jan 10, 2026

Fixes #62954

In theory this could improve the performance of type checking in certain scenarios by avoiding a call to getVariancesWorker as measured in the perfetto profiles.

I've opted to only include some of the most commonly used types, so the added parsing time doesn't outweigh the benefits

I wasn't sure if the explicit specifier needs to be on every expansion of an interface or only the first one, so I've added it to all of them from es5 to esnext, but depending on how the compiler handles it, it could be applied only to the first occurrence of the interface

@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Jan 10, 2026
@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Jan 10, 2026
@typescript-bot
Copy link
Collaborator

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

@akaltar
Copy link
Author

akaltar commented Jan 10, 2026

@microsoft-github-policy-service agree

@jakebailey
Copy link
Member

I'm 99% certain we can't do this, but, curious

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 12, 2026

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

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

@ritschwumm
Copy link

@akaltar sorry, but this is wrong in so far as it subverts type-safety.

take Map for example:
get(key: K): V | undefined; is indeed covariant in V, so out V would make sense.
set(key: K, value: V): this; on the other hand is contravariant in V, so only in V would be correct.

more generally: as long as you have a mutable collection, you cannot define its values covariant.

@typescript-bot
Copy link
Collaborator

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

Everything looks the same!

You can check the log here.

@typescript-bot
Copy link
Collaborator

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

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Package install failed"
  • 1 instance of "Git clone failed"

Otherwise...

Something interesting changed - please have a look.

Details

webpack

tsconfig.types.test.json

tsconfig.types.json

tsconfig.json

@typescript-bot
Copy link
Collaborator

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

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-Unions - node (v18.15.0, x64)
Errors 1 1 ~ ~ ~ p=1.000 n=6
Symbols 62,370 62,400 +30 (+ 0.05%) ~ ~ p=0.001 n=6
Types 50,387 50,435 +48 (+ 0.10%) ~ ~ p=0.001 n=6
Memory used 194,982k (± 0.89%) 193,334k (± 0.75%) ~ 192,650k 196,293k p=0.378 n=6
Parse Time 1.30s (± 0.40%) 1.30s (± 0.58%) ~ 1.29s 1.31s p=0.241 n=6
Bind Time 0.76s 0.76s ~ ~ ~ p=1.000 n=6
Check Time 9.88s (± 0.47%) 9.88s (± 0.42%) ~ 9.81s 9.92s p=0.627 n=6
Emit Time 2.75s (± 0.72%) 2.74s (± 0.63%) ~ 2.72s 2.77s p=0.745 n=6
Total Time 14.69s (± 0.25%) 14.68s (± 0.31%) ~ 14.62s 14.74s p=0.872 n=6
angular-1 - node (v18.15.0, x64)
Errors 2 2 ~ ~ ~ p=1.000 n=6
Symbols 955,823 955,416 -407 (- 0.04%) ~ ~ p=0.001 n=6
Types 415,853 415,617 -236 (- 0.06%) ~ ~ p=0.001 n=6
Memory used 1,253,923k (± 0.01%) 1,253,594k (± 0.00%) -330k (- 0.03%) 1,253,528k 1,253,647k p=0.005 n=6
Parse Time 6.52s (± 0.68%) 6.51s (± 0.30%) ~ 6.49s 6.53s p=0.685 n=6
Bind Time 1.96s (± 0.42%) 1.96s (± 0.32%) ~ 1.95s 1.97s p=0.432 n=6
Check Time 32.43s (± 0.25%) 32.44s (± 0.37%) ~ 32.29s 32.59s p=1.000 n=6
Emit Time 14.99s (± 0.17%) 14.87s (± 0.33%) -0.12s (- 0.80%) 14.79s 14.93s p=0.005 n=6
Total Time 55.90s (± 0.19%) 55.78s (± 0.21%) ~ 55.65s 55.95s p=0.109 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,699,165 2,698,796 -369 (- 0.01%) ~ ~ p=0.001 n=6
Types 937,297 937,089 -208 (- 0.02%) ~ ~ p=0.001 n=6
Memory used 3,028,591k (± 0.00%) 3,028,267k (± 0.00%) -324k (- 0.01%) 3,028,189k 3,028,358k p=0.005 n=6
Parse Time 8.64s (± 0.37%) 8.62s (± 0.28%) ~ 8.59s 8.66s p=0.368 n=6
Bind Time 2.29s (± 0.55%) 2.28s (± 0.60%) ~ 2.26s 2.30s p=0.506 n=6
Check Time 93.63s (± 0.12%) 93.77s (± 0.46%) ~ 93.28s 94.46s p=0.810 n=6
Emit Time 0.31s 0.31s (± 1.31%) ~ 0.31s 0.32s p=0.405 n=6
Total Time 104.87s (± 0.10%) 104.99s (± 0.41%) ~ 104.51s 105.68s p=0.873 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,252,015 1,250,004 -2,011 (- 0.16%) ~ ~ p=0.001 n=6
Types 259,850 258,728 -1,122 (- 0.43%) ~ ~ p=0.001 n=6
Memory used 2,509,153k (±11.87%) 2,506,859k (±11.82%) -2,294k (- 0.09%) 2,385,348k 3,112,520k p=0.045 n=6
Parse Time 5.15s (± 1.47%) 5.20s (± 1.02%) ~ 5.16s 5.30s p=0.229 n=6
Bind Time 1.87s (± 1.04%) 1.85s (± 0.56%) ~ 1.84s 1.87s p=0.138 n=6
Check Time 35.55s (± 0.59%) 35.41s (± 0.39%) ~ 35.28s 35.66s p=0.230 n=6
Emit Time 2.97s (± 1.14%) 2.98s (± 2.44%) ~ 2.88s 3.05s p=0.748 n=6
Total Time 45.56s (± 0.45%) 45.46s (± 0.40%) ~ 45.22s 45.77s p=0.521 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,252,015 1,250,004 -2,011 (- 0.16%) ~ ~ p=0.001 n=6
Types 259,850 258,728 -1,122 (- 0.43%) ~ ~ p=0.001 n=6
Memory used 3,087,475k (± 7.49%) 3,180,208k (± 0.01%) ~ 3,179,542k 3,180,678k p=0.066 n=6
Parse Time 8.37s (± 0.93%) 8.39s (± 0.79%) ~ 8.29s 8.49s p=0.748 n=6
Bind Time 2.77s (± 1.42%) 2.76s (± 0.59%) ~ 2.74s 2.79s p=0.810 n=6
Check Time 53.23s (± 0.77%) 53.10s (± 0.26%) ~ 52.94s 53.30s p=0.128 n=6
Emit Time 4.37s (± 2.27%) 4.32s (± 1.12%) ~ 4.26s 4.39s p=0.109 n=6
Total Time 68.76s (± 0.61%) 68.59s (± 0.23%) ~ 68.38s 68.81s p=0.093 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 264,672 264,244 -428 (- 0.16%) ~ ~ p=0.001 n=6
Types 104,063 103,870 -193 (- 0.19%) ~ ~ p=0.001 n=6
Memory used 443,069k (± 0.01%) 442,582k (± 0.02%) -487k (- 0.11%) 442,425k 442,706k p=0.005 n=6
Parse Time 4.36s (± 0.60%) 4.35s (± 0.84%) ~ 4.30s 4.41s p=0.466 n=6
Bind Time 1.70s (± 1.11%) 1.71s (± 1.13%) ~ 1.69s 1.74s p=0.367 n=6
Check Time 23.82s (± 0.36%) 23.67s (± 0.38%) -0.14s (- 0.61%) 23.54s 23.76s p=0.025 n=6
Emit Time 1.93s (± 1.07%) 1.92s (± 1.27%) ~ 1.89s 1.96s p=0.170 n=6
Total Time 31.81s (± 0.23%) 31.65s (± 0.32%) -0.16s (- 0.50%) 31.50s 31.74s p=0.020 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 72 72 ~ ~ ~ p=1.000 n=6
Symbols 225,493 225,452 -41 (- 0.02%) ~ ~ p=0.001 n=6
Types 94,373 94,349 -24 (- 0.03%) ~ ~ p=0.001 n=6
Memory used 369,971k (± 0.06%) 369,850k (± 0.06%) ~ 369,703k 370,328k p=0.378 n=6
Parse Time 2.83s (± 1.25%) 2.83s (± 0.86%) ~ 2.81s 2.87s p=0.686 n=6
Bind Time 1.64s (± 0.84%) 1.66s (± 1.56%) ~ 1.62s 1.70s p=0.325 n=6
Check Time 16.68s (± 0.29%) 16.63s (± 0.18%) ~ 16.58s 16.66s p=0.088 n=6
Emit Time 0.00s 0.00s (±154.76%) ~ 0.00s 0.01s p=0.174 n=6
Total Time 21.16s (± 0.27%) 21.12s (± 0.24%) ~ 21.05s 21.18s p=0.809 n=6
vscode - node (v18.15.0, x64)
Errors 11 11 ~ ~ ~ p=1.000 n=6
Symbols 4,092,302 4,092,428 +126 (+ 0.00%) ~ ~ p=0.001 n=6
Types 1,292,805 1,292,870 +65 (+ 0.01%) ~ ~ p=0.001 n=6
Memory used 3,885,124k (± 0.00%) 3,885,329k (± 0.01%) ~ 3,885,025k 3,885,803k p=0.230 n=6
Parse Time 19.45s (± 0.49%) 19.40s (± 0.34%) ~ 19.32s 19.47s p=0.520 n=6
Bind Time 6.61s (± 2.57%) 6.68s (± 2.52%) ~ 6.49s 6.87s p=0.471 n=6
Check Time 137.98s (± 2.39%) 137.17s (± 1.10%) ~ 134.68s 138.76s p=0.689 n=6
Emit Time 50.74s (±11.29%) 50.66s (±12.64%) ~ 46.88s 62.83s p=0.471 n=6
Total Time 214.78s (± 2.42%) 213.91s (± 3.34%) ~ 207.71s 227.37s p=0.575 n=6
webpack - node (v18.15.0, x64)
Errors 41 49 🔻+8 (+19.51%) ~ ~ p=0.001 n=6
Symbols 383,772 383,946 +174 (+ 0.05%) ~ ~ p=0.001 n=6
Types 168,183 168,230 +47 (+ 0.03%) ~ ~ p=0.001 n=6
Memory used 542,342k (± 0.01%) 542,444k (± 0.04%) ~ 542,193k 542,796k p=0.470 n=6
Parse Time 4.66s (± 0.68%) 4.65s (± 0.75%) ~ 4.63s 4.71s p=0.624 n=6
Bind Time 2.02s (± 0.77%) 2.01s (± 0.98%) ~ 1.99s 2.04s p=0.514 n=6
Check Time 23.84s (± 0.27%) 23.82s (± 1.37%) ~ 23.25s 24.11s p=1.000 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 30.52s (± 0.27%) 30.49s (± 1.09%) ~ 29.88s 30.78s p=0.748 n=6
xstate-main - node (v18.15.0, x64)
Errors 30 30 ~ ~ ~ p=1.000 n=6
Symbols 696,322 695,557 -765 (- 0.11%) ~ ~ p=0.001 n=6
Types 212,496 211,893 -603 (- 0.28%) ~ ~ p=0.001 n=6
Memory used 590,941k (± 0.02%) 590,230k (± 0.02%) -711k (- 0.12%) 590,117k 590,399k p=0.005 n=6
Parse Time 4.17s (± 0.83%) 4.15s (± 0.72%) ~ 4.11s 4.19s p=0.567 n=6
Bind Time 1.42s (± 1.46%) 1.41s (± 0.94%) ~ 1.39s 1.43s p=0.934 n=6
Check Time 21.53s (± 1.39%) 21.40s (± 1.72%) ~ 20.89s 21.70s p=0.471 n=6
Emit Time 0.00s 0.00s (±244.70%) ~ 0.00s 0.01s p=0.405 n=6
Total Time 27.11s (± 1.11%) 26.97s (± 1.38%) ~ 26.49s 27.28s p=0.422 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Compiler-Unions - node (v18.15.0, x64)
  • angular-1 - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-build-src-public-api - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • ts-pre-modules - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate-main - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

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

Something interesting changed - please have a look.

Details

microsoft/playwright

9 of 13 projects failed to build with the old tsc and were ignored

packages/trace-viewer/tsconfig.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

Explicit variance annotations for built-in .d.ts files

4 participants