TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

Infer type parameters from indexes on those parameters

Open Andarist opened this issue 2 years ago • 41 comments

closes https://github.com/microsoft/TypeScript/issues/51612

Andarist avatar Feb 28 '23 09:02 Andarist

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

typescript-bot avatar Feb 28 '23 09:02 typescript-bot

Status of this PR:

  • it's pretty much done and I await the review and feedback
  • I still think that this feature is especially nice for inferring indexes on reverse mapped types. This PR also enables inferring regular type parameters using those indexes. This is a nice improvement and I don't see many drawbacks of allowing this. However, I feel that a dedicated syntax for declaring/using "generic bags" would be much better. There are things that a dedicated syntax could do that this just can't do. I mentioned all of that in my feature proposal here: https://github.com/microsoft/TypeScript/issues/54254 .
  • the original PR by @weswigham included the "aggregate inference" as an extra candidate. That suffers from some subtle issues as it might impact how supertypes/subtypes are chosen from a set of candidates. I added tests to cover those cases (they were found by the self-check). That's why I only attempt to use the aggregate inference if there are no other candidates in sight. I think it's the best thing to do here.
  • the original PR by @weswigham had a logic for discriminating unions based on the observed usage of the index (a related test case can be seen here). This kind of code is fundamentally unsound since there is no true relation between the argument and the return value. It's impossible to write the implementation of such a function without casting and so on. It could work if a generic would be constrained using an imaginary oneof operator~ but - as it is - I don't think this is OK. For the time being, I retained this logic but I'd like to drop this branch of the code and the related test cases.

Andarist avatar May 22 '23 14:05 Andarist

@weswigham friendly 🏓 I'm really curious about your thoughts on this one 😉

Andarist avatar Jun 05 '23 14:06 Andarist

@weswigham friendly 🏓

Andarist avatar Mar 02 '24 09:03 Andarist

@typescript-bot test it

jakebailey avatar Sep 16 '24 15:09 jakebailey

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

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

typescript-bot avatar Sep 16 '24 15:09 typescript-bot

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

There were interesting changes:

Branch only errors:

Package: node/v16 Error:

Error: 
/mnt/vss/_work/1/DefinitelyTyped/types/node/v16/test/events.ts
  29:49  error  TypeScript@local tsconfig.dom.json, local tsconfig.non-dom.json compile error: 
Type instantiation is excessively deep and possibly infinite  @definitelytyped/expect

✖ 1 problem (1 error, 0 warnings)

    at combineErrorsAndWarnings (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@[email protected][email protected]/node_modules/@definitelytyped/dtslint/dist/index.js:194:28)
    at runTests (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@[email protected][email protected]/node_modules/@definitelytyped/dtslint/dist/index.js:186:20)

Package: node/v18 Error:

Error: 
/mnt/vss/_work/1/DefinitelyTyped/types/node/v18/test/events.ts
  29:49  error  TypeScript@local tsconfig.dom.json, local tsconfig.non-dom.json compile error: 
Type instantiation is excessively deep and possibly infinite  @definitelytyped/expect

✖ 1 problem (1 error, 0 warnings)

    at combineErrorsAndWarnings (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@[email protected][email protected]/node_modules/@definitelytyped/dtslint/dist/index.js:194:28)
    at runTests (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@[email protected][email protected]/node_modules/@definitelytyped/dtslint/dist/index.js:186:20)

Package: rdfjs__data-model Error:

Error: 
/mnt/vss/_work/1/DefinitelyTyped/types/rdfjs__data-model/rdfjs__data-model-tests.ts
  76:5  error  TypeScript@local compile error: 
Unused '@ts-expect-error' directive  @definitelytyped/expect

✖ 1 problem (1 error, 0 warnings)

    at combineErrorsAndWarnings (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@[email protected][email protected]/node_modules/@definitelytyped/dtslint/dist/index.js:194:28)
    at runTests (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@[email protected][email protected]/node_modules/@definitelytyped/dtslint/dist/index.js:186:20)

You can check the log here.

typescript-bot avatar Sep 16 '24 16:09 typescript-bot

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

Something interesting changed - please have a look.

Details

webpack

tsconfig.types.json

  • [NEW] error TS2345: Argument of type 'Comparator<PartialInference<number, keyof PartialInference<number, keyof T>>>' is not assignable to parameter of type '(a: { connection: ModuleGraphConnection; sourceOrder: number; rangeStart: number; }, b: { connection: ModuleGraphConnection; sourceOrder: number; rangeStart: number; }) => number'.

tsconfig.json

  • [NEW] error TS2345: Argument of type 'Comparator<PartialInference<number, keyof PartialInference<number, keyof T>>>' is not assignable to parameter of type '(a: { connection: ModuleGraphConnection; sourceOrder: number; rangeStart: number; }, b: { connection: ModuleGraphConnection; sourceOrder: number; rangeStart: number; }) => number'.

typescript-bot avatar Sep 16 '24 16:09 typescript-bot

@jakebailey, the perf run you requested failed. You can check the log here.

typescript-bot avatar Sep 16 '24 16:09 typescript-bot

@typescript-bot perf test this faster

jakebailey avatar Sep 16 '24 17:09 jakebailey

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

Command Status Results
perf test this faster ✅ Started 👀 Results

typescript-bot avatar Sep 16 '24 17:09 typescript-bot

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

Something interesting changed - please have a look.

Details

Eugeny/tabby

11 of 29 projects failed to build with the old tsc and were ignored

tabby-web-demo/tsconfig.json

tabby-web/tsconfig.json

tabby-terminal/tsconfig.json

tabby-telnet/tsconfig.json

tabby-ssh/tsconfig.json

tabby-settings/tsconfig.json

tabby-serial/tsconfig.json

tabby-plugin-manager/tsconfig.json

tabby-local/tsconfig.json

tabby-linkifier/tsconfig.json

tabby-electron/tsconfig.json

tabby-core/tsconfig.typings.json

tabby-core/tsconfig.json

tabby-community-color-schemes/tsconfig.json

honojs/hono

5 of 6 projects failed to build with the old tsc and were ignored

tsconfig.json

  • error TS2345: Argument of type 'Context<{ Bindings: E["Bindings"] & { eventContext: EventContext<E["Bindings"], any, Record<string, unknown>>; ASSETS: { fetch: { (input: RequestInfo | URL, init?: RequestInit | undefined): Promise<...>; (input: string | ... 1 more ... | URL, init?: RequestInit | undefined): Promise<...>; }; }; }; }, any, {}>' is not assignable to parameter of type 'Context<E & { Bindings: { eventContext: EventContext<{}, any, Record<string, unknown>>; }; }, P, I>'.

mapbox/mapbox-gl-js

1 of 2 projects failed to build with the old tsc and were ignored

tsconfig.json

  • error TS2345: Argument of type 'T & string' is not assignable to parameter of type 'keyof PartialInference<R[T] extends void ? [] : [R[T]], keyof PartialInference<R[T] extends void ? [] : [R[T]], T>>'.
  • error TS2345: Argument of type 'T | keyof PartialInference<R[T] extends void ? [] : [R[T]], T>' is not assignable to parameter of type '(string & {}) | keyof R'.
  • error TS2536: Type 'T | keyof PartialInference<R[T] extends void ? [] : [R[T]], T>' cannot be used to index type 'Listeners<R, unknown>'.
  • error TS2345: Argument of type 'T | keyof PartialInference<R[T] extends void ? [] : [R[T]], T>' is not assignable to parameter of type 'keyof R'.

mendableai/firecrawl

apps/api/tsconfig.json

react-hook-form/react-hook-form

2 of 3 projects failed to build with the old tsc and were ignored

tsconfig.json

typescript-bot avatar Sep 16 '24 17:09 typescript-bot

@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 30 30 ~ ~ ~ p=1.000 n=6
Symbols 62,153 62,190 +37 (+ 0.06%) ~ ~ p=0.001 n=6
Types 50,242 50,312 +70 (+ 0.14%) ~ ~ p=0.001 n=6
Memory used 192,970k (± 0.60%) 193,842k (± 0.90%) ~ 192,525k 196,089k p=0.066 n=6
Parse Time 1.31s (± 0.79%) 1.31s (± 0.57%) ~ 1.30s 1.32s p=0.931 n=6
Bind Time 0.71s 0.71s ~ ~ ~ p=1.000 n=6
Check Time 9.58s (± 0.45%) 9.61s (± 0.38%) ~ 9.56s 9.66s p=0.257 n=6
Emit Time 2.71s (± 1.75%) 2.72s (± 0.43%) ~ 2.70s 2.73s p=0.560 n=6
Total Time 14.31s (± 0.40%) 14.34s (± 0.27%) ~ 14.29s 14.39s p=0.334 n=6
angular-1 - node (v18.15.0, x64)
Errors 7 7 ~ ~ ~ p=1.000 n=6
Symbols 945,753 942,931 -2,822 (- 0.30%) ~ ~ p=0.001 n=6
Types 410,067 409,363 -704 (- 0.17%) ~ ~ p=0.001 n=6
Memory used 1,222,750k (± 0.00%) 1,219,385k (± 0.00%) -3,365k (- 0.28%) 1,219,344k 1,219,410k p=0.005 n=6
Parse Time 6.65s (± 0.19%) 6.67s (± 0.35%) ~ 6.65s 6.71s p=0.088 n=6
Bind Time 1.87s (± 0.28%) 1.87s (± 0.40%) ~ 1.86s 1.88s p=0.784 n=6
Check Time 31.24s (± 0.12%) 31.14s (± 0.47%) ~ 30.94s 31.34s p=0.172 n=6
Emit Time 15.01s (± 0.62%) 15.03s (± 0.53%) ~ 14.90s 15.12s p=0.686 n=6
Total Time 54.76s (± 0.18%) 54.72s (± 0.30%) ~ 54.53s 54.93s p=0.748 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,520,527 2,518,728 -1,799 (- 0.07%) ~ ~ p=0.001 n=6
Types 935,974 934,799 -1,175 (- 0.13%) ~ ~ p=0.001 n=6
Memory used 2,350,373k (± 0.00%) 2,347,084k (± 0.00%) -3,289k (- 0.14%) 2,346,982k 2,347,212k p=0.005 n=6
Parse Time 9.28s (± 0.15%) 9.28s (± 0.38%) ~ 9.25s 9.34s p=0.518 n=6
Bind Time 2.15s (± 0.35%) 2.14s (± 0.76%) ~ 2.11s 2.15s p=0.230 n=6
Check Time 73.29s (± 0.38%) 72.38s (± 0.43%) -0.91s (- 1.25%) 72.15s 72.97s p=0.005 n=6
Emit Time 0.28s (± 1.86%) 0.28s (± 2.95%) ~ 0.26s 0.28s p=0.752 n=6
Total Time 85.00s (± 0.33%) 84.07s (± 0.38%) -0.93s (- 1.09%) 83.86s 84.69s p=0.005 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,245,769 1,246,141 +372 (+ 0.03%) ~ ~ p=0.001 n=6
Types 264,202 265,123 +921 (+ 0.35%) ~ ~ p=0.001 n=6
Memory used 2,397,199k (± 0.02%) 2,398,103k (± 0.02%) +904k (+ 0.04%) 2,397,252k 2,398,735k p=0.020 n=6
Parse Time 5.11s (± 0.96%) 5.11s (± 0.65%) ~ 5.08s 5.17s p=0.810 n=6
Bind Time 1.92s (± 0.42%) 1.90s (± 0.54%) -0.02s (- 1.04%) 1.89s 1.92s p=0.014 n=6
Check Time 34.86s (± 0.59%) 34.91s (± 0.82%) ~ 34.53s 35.20s p=0.936 n=6
Emit Time 3.09s (± 4.76%) 3.07s (± 3.89%) ~ 2.96s 3.27s p=0.810 n=6
Total Time 44.98s (± 0.65%) 45.02s (± 0.62%) ~ 44.51s 45.28s p=0.936 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,245,769 1,246,141 +372 (+ 0.03%) ~ ~ p=0.001 n=6
Types 264,202 265,123 +921 (+ 0.35%) ~ ~ p=0.001 n=6
Memory used 2,471,498k (± 0.04%) 2,473,095k (± 0.04%) +1,597k (+ 0.06%) 2,471,800k 2,474,271k p=0.031 n=6
Parse Time 6.34s (± 0.54%) 6.34s (± 0.40%) ~ 6.30s 6.36s p=0.936 n=6
Bind Time 2.05s (± 0.40%) 2.05s (± 0.91%) ~ 2.02s 2.07s p=1.000 n=6
Check Time 41.45s (± 0.67%) 41.73s (± 0.89%) ~ 41.28s 42.10s p=0.298 n=6
Emit Time 3.69s (± 4.99%) 3.63s (± 4.54%) ~ 3.46s 3.95s p=0.689 n=6
Total Time 53.52s (± 0.37%) 53.76s (± 0.64%) ~ 53.15s 54.06s p=0.173 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 259,878 259,991 +113 (+ 0.04%) ~ ~ p=0.001 n=6
Types 106,139 106,532 +393 (+ 0.37%) ~ ~ p=0.001 n=6
Memory used 435,624k (± 0.01%) 435,914k (± 0.03%) +290k (+ 0.07%) 435,792k 436,149k p=0.005 n=6
Parse Time 3.44s (± 0.77%) 3.43s (± 0.29%) ~ 3.42s 3.44s p=0.870 n=6
Bind Time 1.29s (± 1.06%) 1.30s (± 0.63%) ~ 1.29s 1.31s p=0.181 n=6
Check Time 18.16s (± 0.39%) 18.16s (± 0.18%) ~ 18.11s 18.20s p=0.871 n=6
Emit Time 1.51s (± 0.69%) 1.54s (± 1.67%) ~ 1.50s 1.57s p=0.063 n=6
Total Time 24.41s (± 0.24%) 24.43s (± 0.17%) ~ 24.38s 24.49s p=0.574 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 68 68 ~ ~ ~ p=1.000 n=6
Symbols 225,018 225,119 +101 (+ 0.04%) ~ ~ p=0.001 n=6
Types 94,249 94,612 +363 (+ 0.39%) ~ ~ p=0.001 n=6
Memory used 370,233k (± 0.02%) 370,561k (± 0.03%) +329k (+ 0.09%) 370,445k 370,707k p=0.005 n=6
Parse Time 2.77s (± 0.90%) 2.77s (± 0.78%) ~ 2.74s 2.80s p=0.936 n=6
Bind Time 1.57s (± 2.11%) 1.57s (± 1.19%) ~ 1.53s 1.58s p=1.000 n=6
Check Time 15.78s (± 0.36%) 15.82s (± 0.19%) ~ 15.77s 15.85s p=0.199 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 20.11s (± 0.33%) 20.15s (± 0.17%) ~ 20.11s 20.19s p=0.147 n=6
vscode - node (v18.15.0, x64)
Errors 1 1 ~ ~ ~ p=1.000 n=6
Symbols 3,065,376 3,064,897 -479 (- 0.02%) ~ ~ p=0.001 n=6
Types 1,058,725 1,058,375 -350 (- 0.03%) ~ ~ p=0.001 n=6
Memory used 3,171,032k (± 0.00%) 3,170,119k (± 0.00%) -913k (- 0.03%) 3,170,048k 3,170,167k p=0.005 n=6
Parse Time 13.85s (± 0.36%) 13.84s (± 0.42%) ~ 13.78s 13.94s p=0.747 n=6
Bind Time 4.46s (± 2.69%) 4.49s (± 1.98%) ~ 4.31s 4.54s p=1.000 n=6
Check Time 81.01s (± 0.17%) 81.00s (± 0.45%) ~ 80.71s 81.69s p=0.521 n=6
Emit Time 22.32s (± 0.67%) 22.04s (± 0.34%) -0.29s (- 1.28%) 21.94s 22.13s p=0.008 n=6
Total Time 121.65s (± 0.26%) 121.37s (± 0.37%) ~ 121.02s 122.20s p=0.228 n=6
webpack - node (v18.15.0, x64)
Errors 0 1 🔻+1 (+ ∞%) ~ ~ p=0.001 n=6
Symbols 277,156 275,983 -1,173 (- 0.42%) ~ ~ p=0.001 n=6
Types 112,946 111,976 -970 (- 0.86%) ~ ~ p=0.001 n=6
Memory used 426,926k (± 0.01%) 426,053k (± 0.01%) -874k (- 0.20%) 425,978k 426,117k p=0.005 n=6
Parse Time 3.95s (± 0.41%) 3.94s (± 0.30%) ~ 3.93s 3.96s p=0.216 n=6
Bind Time 1.72s (± 0.30%) 1.70s (± 1.47%) ~ 1.66s 1.73s p=0.352 n=6
Check Time 17.58s (± 0.33%) 17.70s (± 0.37%) +0.12s (+ 0.70%) 17.60s 17.77s p=0.020 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 23.25s (± 0.27%) 23.34s (± 0.36%) ~ 23.20s 23.42s p=0.107 n=6
xstate-main - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 531,582 531,541 -41 (- 0.01%) ~ ~ p=0.001 n=6
Types 181,676 181,726 +50 (+ 0.03%) ~ ~ p=0.001 n=6
Memory used 463,705k (± 0.01%) 463,658k (± 0.01%) ~ 463,569k 463,749k p=0.230 n=6
Parse Time 3.87s (± 0.30%) 3.87s (± 0.38%) ~ 3.85s 3.89s p=1.000 n=6
Bind Time 1.38s (± 0.59%) 1.38s (± 0.54%) ~ 1.37s 1.39s p=0.340 n=6
Check Time 22.61s (± 0.18%) 22.53s (± 0.35%) ~ 22.46s 22.68s p=0.065 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 27.86s (± 0.12%) 27.77s (± 0.30%) ~ 27.68s 27.93s p=0.065 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 avatar Sep 16 '24 18:09 typescript-bot

@typescript-bot pack this

jakebailey avatar Sep 16 '24 18:09 jakebailey

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

Command Status Results
pack this ✅ Started ✅ Results

typescript-bot avatar Sep 16 '24 18:09 typescript-bot

Hey @jakebailey, 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/163583/artifacts?artifactName=tgz&fileId=382726B29C1E4F0DB6DA262450365794DC24B4866B4420BB65B73E1F4BDB587B02&fileName=/typescript-5.7.0-insiders.20240916.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 avatar Sep 16 '24 18:09 typescript-bot

I can't say I'm an expert here but I can certainly try to review it if/when things are settled; I'm just always one to run extended tests and make playgrounds 😄

jakebailey avatar Sep 16 '24 19:09 jakebailey

cross-linking #20126 here (it's mentioned above but hard to find)

jcalz avatar Dec 12 '24 13:12 jcalz

@typescript-bot test it @typescript-bot pack this

jakebailey avatar Nov 29 '25 13:11 jakebailey

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

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

typescript-bot avatar Nov 29 '25 13:11 typescript-bot

Hey @jakebailey, 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/166614/artifacts?artifactName=tgz&fileId=A18FCB6060422A184501D7542607B86C9AD402D972F8C3BBB597043053C0200602&fileName=/typescript-6.0.0-insiders.20251129.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 avatar Nov 29 '25 13:11 typescript-bot

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

There were interesting changes:

Branch only errors:

Package: rdfjs__data-model Error:

Error: 
/mnt/vss/_work/1/DefinitelyTyped/types/rdfjs__data-model/rdfjs__data-model-tests.ts
  76:5  error  TypeScript@local compile error: 
Unused '@ts-expect-error' directive  @definitelytyped/expect

✖ 1 problem (1 error, 0 warnings)

    at combineErrorsAndWarnings (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@[email protected][email protected]/node_modules/@definitelytyped/dtslint/dist/index.js:199:28)
    at runTests (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@[email protected][email protected]/node_modules/@definitelytyped/dtslint/dist/index.js:191:20)

You can check the log here.

typescript-bot avatar Nov 29 '25 13:11 typescript-bot

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

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Git clone failed"

Otherwise...

Something interesting changed - please have a look.

Details

webpack

tsconfig.types.test.json

  • [NEW] error TS2345: Argument of type 'Comparator<PartialInference<number, keyof T>>' is not assignable to parameter of type '(a: { connection: ModuleGraphConnection; sourceOrder: number; rangeStart: number | undefined; defer?: boolean | undefined; }, b: { connection: ModuleGraphConnection; sourceOrder: number; rangeStart: number | undefined; defer?: boolean | undefined; }) => number'.

tsconfig.types.json

  • [NEW] error TS2345: Argument of type 'Comparator<PartialInference<number, keyof T>>' is not assignable to parameter of type '(a: { connection: ModuleGraphConnection; sourceOrder: number; rangeStart: number | undefined; defer?: boolean | undefined; }, b: { connection: ModuleGraphConnection; sourceOrder: number; rangeStart: number | undefined; defer?: boolean | undefined; }) => number'.

tsconfig.json

  • [NEW] error TS2345: Argument of type 'Comparator<PartialInference<number, keyof T>>' is not assignable to parameter of type '(a: { connection: ModuleGraphConnection; sourceOrder: number; rangeStart: number | undefined; defer?: boolean | undefined; }, b: { connection: ModuleGraphConnection; sourceOrder: number; rangeStart: number | undefined; defer?: boolean | undefined; }) => number'.

typescript-bot avatar Nov 29 '25 13:11 typescript-bot

@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,407 +37 (+ 0.06%) ~ ~ p=0.001 n=6
Types 50,386 50,456 +70 (+ 0.14%) ~ ~ p=0.001 n=6
Memory used 195,583k (± 0.73%) 195,750k (± 0.76%) ~ 192,727k 196,520k p=0.173 n=6
Parse Time 1.61s (± 1.35%) 1.60s (± 0.73%) ~ 1.58s 1.61s p=1.000 n=6
Bind Time 0.91s (± 1.89%) 0.91s (± 1.14%) ~ 0.89s 0.92s p=0.867 n=6
Check Time 12.02s (± 0.55%) 12.09s (± 0.56%) ~ 12.02s 12.19s p=0.128 n=6
Emit Time 3.47s (± 4.18%) 3.48s (± 4.86%) ~ 3.25s 3.67s p=0.936 n=6
Total Time 18.00s (± 1.02%) 18.08s (± 1.01%) ~ 17.79s 18.30s p=0.471 n=6
angular-1 - node (v18.15.0, x64)
Errors 2 2 ~ ~ ~ p=1.000 n=6
Symbols 956,047 949,794 -6,253 (- 0.65%) ~ ~ p=0.001 n=6
Types 415,881 411,886 -3,995 (- 0.96%) ~ ~ p=0.001 n=6
Memory used 1,255,206k (± 0.01%) 1,246,711k (± 0.01%) -8,496k (- 0.68%) 1,246,538k 1,246,808k p=0.005 n=6
Parse Time 7.97s (± 0.88%) 8.00s (± 1.00%) ~ 7.88s 8.10s p=0.748 n=6
Bind Time 2.37s (± 0.99%) 2.36s (± 0.44%) ~ 2.34s 2.37s p=0.677 n=6
Check Time 38.72s (± 0.25%) 38.55s (± 0.24%) -0.16s (- 0.42%) 38.41s 38.69s p=0.030 n=6
Emit Time 17.82s (± 0.37%) 17.83s (± 0.52%) ~ 17.73s 17.94s p=0.748 n=6
Total Time 66.88s (± 0.22%) 66.74s (± 0.19%) ~ 66.56s 66.90s p=0.199 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,724,073 2,722,079 -1,994 (- 0.07%) ~ ~ p=0.001 n=6
Types 937,413 936,057 -1,356 (- 0.14%) ~ ~ p=0.001 n=6
Memory used 3,053,390k (± 0.00%) 3,049,812k (± 0.00%) -3,578k (- 0.12%) 3,049,746k 3,050,014k p=0.005 n=6
Parse Time 10.53s (± 0.26%) 10.47s (± 0.32%) -0.06s (- 0.57%) 10.43s 10.53s p=0.015 n=6
Bind Time 2.80s (± 0.73%) 2.83s (± 0.69%) +0.04s (+ 1.25%) 2.80s 2.86s p=0.022 n=6
Check Time 112.93s (± 0.74%) 111.46s (± 0.94%) -1.47s (- 1.30%) 110.16s 113.20s p=0.045 n=6
Emit Time 0.38s (± 2.13%) 0.38s (± 1.97%) ~ 0.37s 0.39s p=0.729 n=6
Total Time 126.64s (± 0.68%) 125.14s (± 0.83%) -1.50s (- 1.18%) 123.78s 126.85s p=0.031 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,251,545 1,251,909 +364 (+ 0.03%) ~ ~ p=0.001 n=6
Types 259,756 260,673 +917 (+ 0.35%) ~ ~ p=0.001 n=6
Memory used 2,392,822k (± 0.02%) 2,515,181k (± 7.47%) 🔻+122,359k (+ 5.11%) 2,393,137k 2,758,301k p=0.020 n=6
Parse Time 5.15s (± 0.63%) 5.18s (± 0.63%) ~ 5.15s 5.24s p=0.127 n=6
Bind Time 1.84s (± 1.41%) 1.82s (± 0.54%) ~ 1.80s 1.83s p=0.294 n=6
Check Time 35.46s (± 0.28%) 35.44s (± 0.84%) ~ 35.02s 35.66s p=0.378 n=6
Emit Time 3.01s (± 1.18%) 3.02s (± 1.46%) ~ 2.98s 3.08s p=0.572 n=6
Total Time 45.46s (± 0.17%) 45.47s (± 0.68%) ~ 45.05s 45.74s p=0.378 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,251,545 1,251,909 +364 (+ 0.03%) ~ ~ p=0.001 n=6
Types 259,756 260,673 +917 (+ 0.35%) ~ ~ p=0.001 n=6
Memory used 3,067,269k (± 9.64%) 3,189,676k (± 0.02%) +122,407k (+ 3.99%) 3,188,780k 3,190,607k p=0.005 n=6
Parse Time 6.74s (± 1.45%) 6.81s (± 0.69%) ~ 6.74s 6.86s p=0.227 n=6
Bind Time 2.27s (± 1.77%) 2.25s (± 1.11%) ~ 2.22s 2.28s p=0.374 n=6
Check Time 43.03s (± 0.33%) 43.18s (± 0.41%) ~ 42.88s 43.41s p=0.093 n=6
Emit Time 3.46s (± 2.80%) 3.48s (± 2.31%) ~ 3.33s 3.55s p=0.936 n=6
Total Time 55.50s (± 0.41%) 55.72s (± 0.34%) ~ 55.50s 56.01s p=0.109 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 264,177 264,289 +112 (+ 0.04%) ~ ~ p=0.001 n=6
Types 103,979 104,368 +389 (+ 0.37%) ~ ~ p=0.001 n=6
Memory used 443,190k (± 0.01%) 443,409k (± 0.01%) +219k (+ 0.05%) 443,349k 443,486k p=0.005 n=6
Parse Time 3.51s (± 1.00%) 3.52s (± 0.87%) ~ 3.49s 3.57s p=0.687 n=6
Bind Time 1.38s (± 0.55%) 1.38s (± 1.63%) ~ 1.34s 1.41s p=1.000 n=6
Check Time 19.22s (± 0.30%) 19.20s (± 0.34%) ~ 19.10s 19.27s p=0.630 n=6
Emit Time 1.54s (± 0.68%) 1.55s (± 1.03%) ~ 1.53s 1.57s p=0.742 n=6
Total Time 25.66s (± 0.19%) 25.65s (± 0.33%) ~ 25.50s 25.73s p=0.872 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 72 72 ~ ~ ~ p=1.000 n=6
Symbols 225,386 225,487 +101 (+ 0.04%) ~ ~ p=0.001 n=6
Types 94,304 94,667 +363 (+ 0.38%) ~ ~ p=0.001 n=6
Memory used 370,038k (± 0.01%) 370,311k (± 0.04%) +273k (+ 0.07%) 370,164k 370,620k p=0.005 n=6
Parse Time 2.83s (± 0.94%) 2.83s (± 1.74%) ~ 2.76s 2.91s p=0.936 n=6
Bind Time 1.64s (± 1.78%) 1.64s (± 1.05%) ~ 1.62s 1.67s p=0.936 n=6
Check Time 16.56s (± 0.42%) 16.62s (± 0.15%) ~ 16.60s 16.67s p=0.065 n=6
Emit Time 0.00s 0.00s (±244.70%) ~ 0.00s 0.01s p=0.405 n=6
Total Time 21.03s (± 0.38%) 21.10s (± 0.33%) ~ 21.00s 21.20s p=0.090 n=6
vscode - node (v18.15.0, x64)
Errors 11 11 ~ ~ ~ p=1.000 n=6
Symbols 4,068,329 4,067,797 -532 (- 0.01%) ~ ~ p=0.001 n=6
Types 1,281,534 1,281,044 -490 (- 0.04%) ~ ~ p=0.001 n=6
Memory used 3,854,255k (± 0.00%) 3,853,351k (± 0.00%) -904k (- 0.02%) 3,853,221k 3,853,736k p=0.005 n=6
Parse Time 15.72s (± 0.63%) 15.66s (± 0.73%) ~ 15.53s 15.86s p=0.173 n=6
Bind Time 5.29s (± 1.14%) 5.27s (± 0.33%) ~ 5.24s 5.29s p=1.000 n=6
Check Time 110.31s (± 3.17%) 112.44s (± 2.73%) +2.13s (+ 1.93%) 110.74s 118.53s p=0.045 n=6
Emit Time 40.90s (± 8.55%) 41.05s (±12.20%) ~ 38.58s 51.25s p=1.000 n=6
Total Time 172.22s (± 2.26%) 174.42s (± 4.66%) ~ 170.25s 190.93s p=0.378 n=6
webpack - node (v18.15.0, x64)
Errors 40 41 +1 (+ 2.50%) ~ ~ p=0.001 n=6
Symbols 379,892 378,698 -1,194 (- 0.31%) ~ ~ p=0.001 n=6
Types 166,631 165,761 -870 (- 0.52%) ~ ~ p=0.001 n=6
Memory used 539,851k (± 0.01%) 538,974k (± 0.02%) -877k (- 0.16%) 538,910k 539,132k p=0.005 n=6
Parse Time 3.88s (± 0.35%) 3.90s (± 0.85%) ~ 3.87s 3.96s p=0.618 n=6
Bind Time 1.67s (± 1.28%) 1.67s (± 0.73%) ~ 1.66s 1.69s p=0.744 n=6
Check Time 19.09s (± 0.29%) 19.08s (± 0.49%) ~ 18.98s 19.20s p=0.748 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 24.65s (± 0.17%) 24.65s (± 0.51%) ~ 24.52s 24.81s p=0.810 n=6
xstate-main - node (v18.15.0, x64)
Errors 30 31 +1 (+ 3.33%) ~ ~ p=0.001 n=6
Symbols 690,397 690,345 -52 (- 0.01%) ~ ~ p=0.001 n=6
Types 208,790 209,035 +245 (+ 0.12%) ~ ~ p=0.001 n=6
Memory used 586,112k (± 0.03%) 586,171k (± 0.03%) ~ 586,012k 586,333k p=0.471 n=6
Parse Time 4.17s (± 0.58%) 4.16s (± 0.45%) ~ 4.14s 4.18s p=0.807 n=6
Bind Time 1.41s (± 1.10%) 1.41s (± 1.22%) ~ 1.39s 1.44s p=0.803 n=6
Check Time 20.76s (± 1.53%) 20.64s (± 1.72%) ~ 20.30s 21.21s p=0.689 n=6
Emit Time 0.01s (±109.43%) 0.00s (±154.76%) ~ 0.00s 0.01s p=0.640 n=6
Total Time 26.34s (± 1.22%) 26.22s (± 1.41%) ~ 25.87s 26.82s p=0.748 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 avatar Nov 29 '25 14:11 typescript-bot

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

Something interesting changed - please have a look.

Details

react-navigation/react-navigation

7 of 14 projects failed to build with the old tsc and were ignored

tsconfig.json

example/tsconfig.json

tldraw/tldraw

30 of 34 projects failed to build with the old tsc and were ignored

templates/branching-chat/tsconfig.json

  • error TS2345: Argument of type '{ x: number; y: number; id: TLShapeId; typeName: "shape"; type: "node"; rotation: number; index: IndexKey; parentId: TLParentId; isLocked: boolean; opacity: TLOpacityType; props: { ...; }; meta: JsonObject; }' is not assignable to parameter of type 'null | undefined'.

typescript-bot avatar Nov 29 '25 14:11 typescript-bot

@typescript-bot test it @typescript-bot pack this

jakebailey avatar Dec 01 '25 19:12 jakebailey

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

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

typescript-bot avatar Dec 01 '25 19:12 typescript-bot

Hey @jakebailey, 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/166633/artifacts?artifactName=tgz&fileId=E5F9CEBCCB3B4DBB52F1F9642B36C892BB89227CBD41EAD91C6DBFD5FA8129EC02&fileName=/typescript-6.0.0-insiders.20251201.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 avatar Dec 01 '25 19:12 typescript-bot

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

There were interesting changes:

Branch only errors:

Package: rdfjs__data-model Error:

Error: 
/mnt/vss/_work/1/DefinitelyTyped/types/rdfjs__data-model/rdfjs__data-model-tests.ts
  76:5  error  TypeScript@local compile error: 
Unused '@ts-expect-error' directive  @definitelytyped/expect

✖ 1 problem (1 error, 0 warnings)

    at combineErrorsAndWarnings (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@[email protected][email protected]/node_modules/@definitelytyped/dtslint/dist/index.js:199:28)
    at runTests (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@[email protected][email protected]/node_modules/@definitelytyped/dtslint/dist/index.js:191:20)

You can check the log here.

typescript-bot avatar Dec 01 '25 20:12 typescript-bot