Skip to content

Fix ghost errors resulting from out-of-order type checking - #58337

Merged
Anders Hejlsberg (ahejlsberg) merged 9 commits into
mainfrom
fix57585
Apr 29, 2024
Merged

Fix ghost errors resulting from out-of-order type checking#58337
Anders Hejlsberg (ahejlsberg) merged 9 commits into
mainfrom
fix57585

Conversation

@ahejlsberg

@ahejlsbergAnders Hejlsberg (ahejlsberg) commented Apr 26, 2024

Copy link
Copy Markdown
Member

This PR introduces logic that suppresses ghost errors resulting from "inverted" type checking situations where, for example, an API client asks for the type of a symbol in the middle of a section of code, causing type resolution to occur in a different order than when the code is checked from top to bottom in a regular compilation.

Some context on the fix in this PR. In this example

functionbuilder(def: IThing){returndef;}interfaceIThing{doThing: (args: {value: object})=>stringargs: {value: number}}builder({doThing(args: {value: object}){const{ value }=this.args;// Ghost circularity error on "value"return`${value}`},args: {value: 42}});

a circularity error is reported in the VS Code IDE, but no error is reported with the command-line compiler. The issue is that the IDE language service requests type information on identifiers in the code (likely for semantic classification, but doesn't really matter) before it requests the full list of diagnostics for the code. Specifically, a request is initially made for getTypeOfSymbol for the symbol of the value identifier. This causes resolution of this.args, and to resolve the type of this, a request is made for the contextual type of the object literal passed as an argument in the builder({...}) call. That in turn means we need to resolve the signature for the call, which in turn means resolving the type of the arguments, which in turn means obtaining the type of the {...} object literal argument, which further requires resolving the return type of doThing, which gets us back to a second getTypeOfSymbol call for value. And we have a circularity.

However, in the regular top-to-bottom sweep to produce diagnostics, we request resolving the signature of the builder({...}) call first, which eventually gets us to a getTypeOfSymbol for value, which in turn requests the contextual type for the object literal. We then see that we're in the process of resolving the signature of the containing builder({...}) call, and therefore we simply report that there is no contextual type. And thus no circularity.

With the fix in this PR, we temporarily reset the resolution stack during getResolvedSignature calls. In the IDE scenario this means that the first call to getTypeOfSymbol is no longer reflected on the resolution stack, so resolution can proceed in the same manner as the regular case. Following that, the outer getTypeOfSymbol call notices that a resolved type has already been recorded, so it simply proceeds with that. No circularity, and all is well.

Fixes#57429.
Fixes#57585.

@ahejlsberg

Copy link
Copy Markdown
MemberAuthor

@typescript-bot

TypeScript Bot (typescript-bot) commented Apr 26, 2024

Copy link
Copy Markdown
Contributor

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

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

@ahejlsberg

Copy link
Copy Markdown
MemberAuthor

TypeScript Bot (@typescript-bot) pack this

@typescript-bot

TypeScript Bot (typescript-bot) commented Apr 26, 2024

Copy link
Copy Markdown
Contributor

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

CommandStatusResults
pack this✅ Started✅ Results

@typescript-bot

TypeScript Bot (typescript-bot) commented Apr 26, 2024

Copy link
Copy Markdown
Contributor

Hey Anders Hejlsberg (@ahejlsberg), 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/161498/artifacts?artifactName=tgz&fileId=FC3BCEFCEC65EC0872BF4A014DB519141AE7906101F9BC5D7289BBA167D4517302&fileName=/typescript-5.5.0-insiders.20240426.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.5.0-pr-58337-4".;

@jakebailey

Jake Bailey (jakebailey) commented Apr 26, 2024

Copy link
Copy Markdown
Member

You should be able to pull the tests from Andarist's comments, i.e. copy these ones: https://github.com/microsoft/TypeScript/pull/58323/files#diff-8814cff6472937bf39f151270b038e16552d0896cc67cb5c5382aa432c909acf (though with better filenames than mine)

I tested locally by pulling this code into my branch and it seemed to work!

@typescript-bot

Copy link
Copy Markdown
Contributor

Hey Anders Hejlsberg (@ahejlsberg), 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

Anders Hejlsberg (@ahejlsberg) Here are the results of running the user tests comparing main and refs/pull/58337/merge:

Something interesting changed - please have a look.

Details

webpack

tsconfig.types.json

@typescript-bot

Copy link
Copy Markdown
Contributor

Anders Hejlsberg (@ahejlsberg)
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Compiler-Unions - node (v18.15.0, x64)
Errors3030~~~p=1.000 n=6
Symbols62,15462,154~~~p=1.000 n=6
Types50,27350,273~~~p=1.000 n=6
Memory used193,300k (± 0.94%)192,767k (± 0.76%)~192,082k195,748kp=0.230 n=6
Parse Time1.63s (± 1.39%)1.64s (± 1.93%)~1.60s1.67sp=0.224 n=6
Bind Time0.87s (± 0.97%)0.87s (± 1.03%)~0.86s0.88sp=0.339 n=6
Check Time11.35s (± 0.46%)11.29s (± 0.44%)~11.22s11.36sp=0.065 n=6
Emit Time3.12s (± 1.08%)3.15s (± 0.63%)~3.13s3.18sp=0.103 n=6
Total Time16.97s (± 0.48%)16.95s (± 0.45%)~16.88s17.05sp=0.745 n=6
angular-1 - node (v18.15.0, x64)
Errors55~~~p=1.000 n=6
Symbols945,172945,322+150 (+ 0.02%)~~p=0.001 n=6
Types408,068408,088+20 (+ 0.00%)~~p=0.001 n=6
Memory used1,221,995k (± 0.00%)1,222,028k (± 0.01%)~1,221,932k1,222,107kp=0.297 n=6
Parse Time8.21s (± 0.34%)8.22s (± 0.46%)~8.17s8.28sp=0.573 n=6
Bind Time2.23s (± 0.69%)2.24s (± 0.59%)~2.22s2.25sp=0.242 n=6
Check Time36.61s (± 0.32%)36.70s (± 0.34%)~36.59s36.92sp=0.173 n=6
Emit Time17.47s (± 0.33%)17.49s (± 0.95%)~17.27s17.73sp=1.000 n=6
Total Time64.52s (± 0.30%)64.65s (± 0.36%)~64.32s64.99sp=0.298 n=6
mui-docs - node (v18.15.0, x64)
Errors55~~~p=1.000 n=6
Symbols1,954,6351,954,717+82 (+ 0.00%)~~p=0.001 n=6
Types676,418676,452+34 (+ 0.01%)~~p=0.001 n=6
Memory used1,753,418k (± 0.00%)1,753,447k (± 0.00%)~1,753,425k1,753,475kp=0.065 n=6
Parse Time6.90s (± 0.45%)6.90s (± 0.35%)~6.87s6.94sp=0.558 n=6
Bind Time2.31s (± 0.58%)2.31s (± 0.24%)~2.30s2.31sp=0.663 n=6
Check Time56.82s (± 0.23%)56.88s (± 0.43%)~56.58s57.17sp=0.810 n=6
Emit Time0.14s (± 5.31%)0.14s (± 7.20%)~0.13s0.16sp=0.931 n=6
Total Time66.16s (± 0.19%)66.22s (± 0.37%)~65.95s66.51sp=0.936 n=6
self-build-src - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,215,3261,215,327+1 (+ 0.00%)~~p=0.001 n=6
Types257,546257,546~~~p=1.000 n=6
Memory used2,322,567k (± 0.03%)2,556,537k (±14.16%)~2,322,454k3,024,744kp=0.298 n=6
Parse Time7.55s (± 0.34%)7.64s (± 1.55%)~7.53s7.85sp=0.066 n=6
Bind Time2.73s (± 0.54%)2.73s (± 1.24%)~2.69s2.77sp=0.806 n=6
Check Time49.54s (± 0.61%)49.80s (± 0.78%)~49.29s50.27sp=0.298 n=6
Emit Time4.01s (± 3.25%)3.97s (± 0.85%)~3.91s4.00sp=0.520 n=6
Total Time63.84s (± 0.51%)64.14s (± 0.66%)~63.60s64.69sp=0.230 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,215,3261,215,327+1 (+ 0.00%)~~p=0.001 n=6
Types257,546257,546~~~p=1.000 n=6
Memory used2,397,547k (± 0.03%)2,397,197k (± 0.03%)~2,396,608k2,398,552kp=0.230 n=6
Parse Time6.25s (± 0.53%)6.30s (± 0.61%)+0.05s (+ 0.72%)6.22s6.32sp=0.044 n=6
Bind Time1.98s (± 1.15%)2.00s (± 1.24%)~1.97s2.03sp=0.318 n=6
Check Time40.49s (± 0.47%)40.55s (± 0.25%)~40.42s40.67sp=0.810 n=6
Emit Time3.11s (± 1.98%)3.14s (± 1.90%)~3.06s3.22sp=0.520 n=6
Total Time51.86s (± 0.43%)52.01s (± 0.26%)~51.80s52.20sp=0.173 n=6
self-compiler - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols256,101256,102+1 (+ 0.00%)~~p=0.001 n=6
Types103,616103,616~~~p=1.000 n=6
Memory used424,123k (± 0.02%)424,064k (± 0.01%)~424,033k424,085kp=0.109 n=6
Parse Time4.30s (± 0.68%)4.34s (± 0.61%)~4.30s4.36sp=0.053 n=6
Bind Time1.61s (± 1.33%)1.61s (± 1.28%)~1.57s1.63sp=0.871 n=6
Check Time22.47s (± 0.45%)22.50s (± 0.45%)~22.38s22.67sp=0.574 n=6
Emit Time1.75s (± 1.12%)1.76s (± 0.84%)~1.74s1.78sp=0.869 n=6
Total Time30.14s (± 0.38%)30.21s (± 0.33%)~30.10s30.36sp=0.199 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors3535~~~p=1.000 n=6
Symbols224,824224,824~~~p=1.000 n=6
Types93,39093,390~~~p=1.000 n=6
Memory used369,286k (± 0.01%)369,388k (± 0.05%)~369,276k369,742kp=0.173 n=6
Parse Time3.68s (± 0.62%)3.68s (± 0.59%)~3.65s3.71sp=1.000 n=6
Bind Time1.94s (± 1.28%)1.91s (± 1.22%)~1.88s1.95sp=0.105 n=6
Check Time19.46s (± 0.41%)19.44s (± 0.34%)~19.32s19.50sp=0.568 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time25.09s (± 0.30%)25.03s (± 0.29%)~24.90s25.12sp=0.171 n=6
vscode - node (v18.15.0, x64)
Errors44~~~p=1.000 n=6
Symbols2,797,1742,797,178+4 (+ 0.00%)~~p=0.001 n=6
Types950,074950,076+2 (+ 0.00%)~~p=0.001 n=6
Memory used2,925,297k (± 0.00%)2,925,315k (± 0.00%)~2,925,280k2,925,373kp=0.199 n=6
Parse Time16.56s (± 0.26%)16.58s (± 0.36%)~16.51s16.68sp=0.748 n=6
Bind Time4.93s (± 0.42%)4.92s (± 0.51%)~4.88s4.95sp=0.739 n=6
Check Time88.23s (± 0.41%)88.12s (± 0.27%)~87.78s88.41sp=0.575 n=6
Emit Time24.47s (± 7.77%)24.58s (± 7.44%)~23.62s28.30sp=0.521 n=6
Total Time134.19s (± 1.63%)134.19s (± 1.40%)~133.14s138.00sp=0.689 n=6
webpack - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols265,853265,858+5 (+ 0.00%)~~p=0.001 n=6
Types108,438108,445+7 (+ 0.01%)~~p=0.001 n=6
Memory used410,403k (± 0.02%)410,430k (± 0.02%)~410,347k410,509kp=0.521 n=6
Parse Time4.89s (± 0.46%)4.90s (± 0.72%)~4.85s4.94sp=0.685 n=6
Bind Time2.08s (± 0.77%)2.07s (± 0.83%)~2.05s2.09sp=0.321 n=6
Check Time21.15s (± 0.32%)21.14s (± 0.31%)~21.09s21.26sp=0.629 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time28.12s (± 0.20%)28.11s (± 0.13%)~28.07s28.16sp=0.936 n=6
xstate-main - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols523,981524,146+165 (+ 0.03%)~~p=0.001 n=6
Types178,708178,732+24 (+ 0.01%)~~p=0.001 n=6
Memory used461,162k (± 0.01%)461,212k (± 0.01%)~461,124k461,286kp=0.378 n=6
Parse Time2.69s (± 0.87%)2.68s (± 0.51%)~2.66s2.70sp=0.503 n=6
Bind Time0.98s (± 0.42%)0.98s (± 0.42%)~0.97s0.98sp=0.218 n=6
Check Time15.45s (± 0.23%)15.46s (± 0.22%)~15.41s15.50sp=0.520 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time19.11s (± 0.22%)19.11s (± 0.19%)~19.05s19.15sp=0.687 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)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

Developer Information:

Download Benchmarks

@DanielRosenwasser

Copy link
Copy Markdown
Member

Those webpack breaks are kind of weird.

TypeScript Bot (@typescript-bot) test top800

@typescript-bot

TypeScript Bot (typescript-bot) commented Apr 27, 2024

Copy link
Copy Markdown
Contributor

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

CommandStatusResults
test top800✅ Started👀 Results

@ahejlsberg

Copy link
Copy Markdown
MemberAuthor

@typescript-bot

TypeScript Bot (typescript-bot) commented Apr 27, 2024

Copy link
Copy Markdown
Contributor

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

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

@ahejlsberg

Copy link
Copy Markdown
MemberAuthor

Those webpack breaks are kind of weird

With the temporary resetting of the resolution stack, it is now possible for getReturnTypeOfSignature to resolve the same signature twice in a nested manner. When that happens we should always keep the result of the first resolution to complete, and that's now happening with the latest commit.

@typescript-bot

Copy link
Copy Markdown
Contributor

Anders Hejlsberg (@ahejlsberg) Here are the results of running the top 400 repos comparing main and refs/pull/58337/merge:

Something interesting changed - please have a look.

Details

compiler-explorer/compiler-explorer

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

tsconfig.tests.json

tsconfig.json

reduxjs/redux

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

test/tsconfig.json

  • error TS2345: Argument of type '<NextExt extends {}, NextStateExt extends {}>(x: StoreEnhancerStoreCreator<NextExt, NextStateExt>) => StoreEnhancerStoreCreator<NextExt, NextStateExt>' is not assignable to parameter of type 'StoreEnhancer<Store<Todo[], TodoAction, unknown>, {}>'.

tinacms/tinacms

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

packages/@tinacms/cli/tsconfig.json

@typescript-bot

Copy link
Copy Markdown
Contributor

Hey Anders Hejlsberg (@ahejlsberg), 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

Anders Hejlsberg (@ahejlsberg) Here are the results of running the user tests comparing main and refs/pull/58337/merge:

Something interesting changed - please have a look.

Details

webpack

tsconfig.types.json

  • [NEW] error TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.

@typescript-bot

Copy link
Copy Markdown
Contributor

Anders Hejlsberg (@ahejlsberg)
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Compiler-Unions - node (v18.15.0, x64)
Errors3030~~~p=1.000 n=6
Symbols62,15462,154~~~p=1.000 n=6
Types50,27350,273~~~p=1.000 n=6
Memory used192,746k (± 0.77%)192,727k (± 0.76%)~192,038k195,707kp=0.810 n=6
Parse Time1.63s (± 1.59%)1.63s (± 2.16%)~1.60s1.67sp=0.871 n=6
Bind Time0.86s (± 0.73%)0.87s (± 1.19%)~0.86s0.88sp=0.293 n=6
Check Time11.37s (± 0.57%)11.34s (± 0.23%)~11.30s11.37sp=0.572 n=6
Emit Time3.14s (± 0.62%)3.15s (± 0.62%)~3.12s3.17sp=0.289 n=6
Total Time16.99s (± 0.55%)16.98s (± 0.27%)~16.94s17.07sp=1.000 n=6
angular-1 - node (v18.15.0, x64)
Errors55~~~p=1.000 n=6
Symbols945,172945,322+150 (+ 0.02%)~~p=0.001 n=6
Types408,068408,088+20 (+ 0.00%)~~p=0.001 n=6
Memory used1,222,010k (± 0.00%)1,222,091k (± 0.00%)+81k (+ 0.01%)1,222,014k1,222,164kp=0.045 n=6
Parse Time6.92s (± 0.51%)6.91s (± 0.27%)~6.89s6.93sp=0.677 n=6
Bind Time1.87s (± 0.65%)1.87s (± 0.63%)~1.85s1.88sp=0.563 n=6
Check Time31.40s (± 0.34%)31.41s (± 0.14%)~31.37s31.49sp=0.936 n=6
Emit Time14.73s (± 0.29%)14.63s (± 0.50%)-0.10s (- 0.67%)14.56s14.74sp=0.029 n=6
Total Time54.93s (± 0.20%)54.83s (± 0.13%)~54.73s54.91sp=0.173 n=6
mui-docs - node (v18.15.0, x64)
Errors55~~~p=1.000 n=6
Symbols1,954,6351,954,717+82 (+ 0.00%)~~p=0.001 n=6
Types676,418676,452+34 (+ 0.01%)~~p=0.001 n=6
Memory used1,753,435k (± 0.00%)1,753,469k (± 0.00%)+34k (+ 0.00%)1,753,446k1,753,488kp=0.013 n=6
Parse Time6.89s (± 0.46%)6.86s (± 0.36%)~6.83s6.90sp=0.257 n=6
Bind Time2.31s (± 1.07%)2.30s (± 0.35%)~2.30s2.32sp=0.932 n=6
Check Time56.75s (± 0.70%)56.78s (± 0.49%)~56.44s57.29sp=0.810 n=6
Emit Time0.14s (± 2.88%)0.14s~~~p=0.405 n=6
Total Time66.09s (± 0.57%)66.09s (± 0.45%)~65.72s66.63sp=0.873 n=6
self-build-src - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,215,5671,215,568+1 (+ 0.00%)~~p=0.001 n=6
Types257,612257,612~~~p=1.000 n=6
Memory used2,323,057k (± 0.01%)2,323,337k (± 0.01%)~2,322,857k2,323,713kp=0.093 n=6
Parse Time6.11s (± 0.81%)6.07s (± 1.21%)~6.00s6.19sp=0.298 n=6
Bind Time2.22s (± 0.94%)2.22s (± 0.53%)~2.21s2.24sp=0.808 n=6
Check Time39.92s (± 0.10%)39.91s (± 0.40%)~39.74s40.19sp=0.810 n=6
Emit Time3.10s (± 1.30%)3.09s (± 1.32%)~3.04s3.16sp=0.630 n=6
Total Time51.37s (± 0.19%)51.29s (± 0.22%)~51.16s51.50sp=0.149 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,215,5671,215,568+1 (+ 0.00%)~~p=0.001 n=6
Types257,612257,612~~~p=1.000 n=6
Memory used2,514,299k (±11.35%)2,397,814k (± 0.02%)~2,396,993k2,398,524kp=0.810 n=6
Parse Time7.81s (± 1.11%)7.83s (± 0.93%)~7.74s7.91sp=0.575 n=6
Bind Time2.46s (± 1.90%)2.47s (± 1.10%)~2.44s2.50sp=0.807 n=6
Check Time50.40s (± 0.73%)50.38s (± 0.14%)~50.30s50.49sp=0.810 n=6
Emit Time3.92s (± 1.73%)3.92s (± 1.75%)~3.81s4.00sp=1.000 n=6
Total Time64.59s (± 0.51%)64.60s (± 0.20%)~64.49s64.81sp=0.423 n=6
self-compiler - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols256,196256,197+1 (+ 0.00%)~~p=0.001 n=6
Types103,640103,640~~~p=1.000 n=6
Memory used424,214k (± 0.01%)424,242k (± 0.01%)~424,193k424,289kp=0.128 n=6
Parse Time4.29s (± 0.61%)4.31s (± 0.53%)~4.29s4.35sp=0.225 n=6
Bind Time1.59s (± 1.85%)1.62s (± 1.01%)~1.60s1.64sp=0.063 n=6
Check Time22.52s (± 0.37%)22.55s (± 0.37%)~22.41s22.65sp=0.748 n=6
Emit Time1.71s (± 1.41%)1.72s (± 1.63%)~1.67s1.75sp=0.808 n=6
Total Time30.12s (± 0.43%)30.19s (± 0.31%)~30.09s30.35sp=0.377 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors3535~~~p=1.000 n=6
Symbols224,824224,824~~~p=1.000 n=6
Types93,39093,390~~~p=1.000 n=6
Memory used369,306k (± 0.02%)369,322k (± 0.02%)~369,216k369,439kp=1.000 n=6
Parse Time2.96s (± 0.73%)2.97s (± 0.90%)~2.93s2.99sp=0.466 n=6
Bind Time1.59s (± 0.84%)1.58s (± 0.65%)~1.57s1.59sp=0.111 n=6
Check Time15.73s (± 0.47%)15.69s (± 0.31%)~15.62s15.75sp=0.198 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time20.27s (± 0.42%)20.22s (± 0.27%)~20.13s20.29sp=0.261 n=6
vscode - node (v18.15.0, x64)
Errors44~~~p=1.000 n=6
Symbols2,797,1492,797,153+4 (+ 0.00%)~~p=0.001 n=6
Types950,053950,055+2 (+ 0.00%)~~p=0.001 n=6
Memory used2,925,288k (± 0.00%)2,925,275k (± 0.00%)~2,925,072k2,925,396kp=1.000 n=6
Parse Time16.69s (± 0.60%)16.62s (± 0.31%)~16.55s16.69sp=0.258 n=6
Bind Time4.98s (± 0.46%)4.99s (± 0.20%)~4.98s5.00sp=0.677 n=6
Check Time88.77s (± 0.38%)88.60s (± 0.25%)~88.42s88.99sp=0.173 n=6
Emit Time24.60s (± 7.48%)24.68s (± 7.62%)~23.84s28.52sp=0.378 n=6
Total Time135.04s (± 1.53%)134.89s (± 1.35%)~133.90s138.58sp=0.521 n=6
webpack - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols265,853265,858+5 (+ 0.00%)~~p=0.001 n=6
Types108,438108,442+4 (+ 0.00%)~~p=0.001 n=6
Memory used410,429k (± 0.03%)410,408k (± 0.02%)~410,300k410,540kp=0.689 n=6
Parse Time4.86s (± 0.64%)4.89s (± 0.73%)~4.84s4.94sp=0.169 n=6
Bind Time2.07s (± 0.79%)2.07s (± 0.99%)~2.04s2.09sp=0.742 n=6
Check Time21.15s (± 0.48%)21.12s (± 0.52%)~21.02s21.32sp=0.417 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time28.09s (± 0.41%)28.08s (± 0.44%)~27.91s28.27sp=1.000 n=6
xstate-main - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols523,981524,146+165 (+ 0.03%)~~p=0.001 n=6
Types178,708178,732+24 (+ 0.01%)~~p=0.001 n=6
Memory used461,219k (± 0.02%)461,374k (± 0.03%)~461,232k461,499kp=0.066 n=6
Parse Time4.01s (± 0.54%)4.00s (± 0.52%)~3.97s4.03sp=0.462 n=6
Bind Time1.46s (± 0.75%)1.46s (± 1.01%)~1.44s1.48sp=0.805 n=6
Check Time22.57s (± 0.40%)22.63s (± 0.27%)~22.54s22.71sp=0.296 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time28.05s (± 0.32%)28.08s (± 0.16%)~28.03s28.14sp=0.336 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)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

Developer Information:

Download Benchmarks

@typescript-bot

Copy link
Copy Markdown
Contributor

Anders Hejlsberg (@ahejlsberg) Here are the results of running the top 400 repos comparing main and refs/pull/58337/merge:

Something interesting changed - please have a look.

Details

reduxjs/redux

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

test/tsconfig.json

  • error TS2345: Argument of type '<NextExt extends {}, NextStateExt extends {}>(x: StoreEnhancerStoreCreator<NextExt, NextStateExt>) => StoreEnhancerStoreCreator<NextExt, NextStateExt>' is not assignable to parameter of type 'StoreEnhancer<Store<Todo[], TodoAction, unknown>, {}>'.

@ahejlsberg

Copy link
Copy Markdown
MemberAuthor

TypeScript Bot (@typescript-bot) pack this

@typescript-bot

TypeScript Bot (typescript-bot) commented Apr 28, 2024

Copy link
Copy Markdown
Contributor

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

CommandStatusResults
pack this✅ Started✅ Results

@ahejlsberg

Copy link
Copy Markdown
MemberAuthor

@typescript-bot

TypeScript Bot (typescript-bot) commented Apr 28, 2024

Copy link
Copy Markdown
Contributor

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

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

@typescript-bot

TypeScript Bot (typescript-bot) commented Apr 28, 2024

Copy link
Copy Markdown
Contributor

Hey Anders Hejlsberg (@ahejlsberg), 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/161518/artifacts?artifactName=tgz&fileId=CB5DA3E812F57E3C4C788ACABF1555D2EEA4DEB5F82EA948870C429E1CCF051102&fileName=/typescript-5.5.0-insiders.20240428.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.5.0-pr-58337-46".;

@typescript-bot

Copy link
Copy Markdown
Contributor

Hey Anders Hejlsberg (@ahejlsberg), 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

Anders Hejlsberg (@ahejlsberg) Here are the results of running the user tests comparing main and refs/pull/58337/merge:

Something interesting changed - please have a look.

Details

webpack

tsconfig.types.json

  • [NEW] error TS7024: Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.

@mikearnaldi

Copy link
Copy Markdown

Ok, now it fixes the Effect repro. Sorry for the confusion.

Thank you immensely!! This makes a lot of difference for Effect, I will test this tomorrow just to double check that in the large codebase nothing wierd happens.

@typescript-bot

Copy link
Copy Markdown
Contributor

Anders Hejlsberg (@ahejlsberg)
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Compiler-Unions - node (v18.15.0, x64)
Errors3030~~~p=1.000 n=6
Symbols62,15462,154~~~p=1.000 n=6
Types50,27350,273~~~p=1.000 n=6
Memory used193,363k (± 0.94%)192,837k (± 0.72%)~192,105k195,670kp=0.936 n=6
Parse Time1.34s (± 1.68%)1.36s (± 0.98%)~1.34s1.38sp=0.310 n=6
Bind Time0.72s0.72s~~~p=1.000 n=6
Check Time9.56s (± 0.38%)9.56s (± 0.62%)~9.48s9.65sp=0.810 n=6
Emit Time2.61s (± 0.75%)2.62s (± 0.34%)~2.61s2.63sp=0.357 n=6
Total Time14.24s (± 0.26%)14.26s (± 0.43%)~14.19s14.36sp=0.872 n=6
angular-1 - node (v18.15.0, x64)
Errors55~~~p=1.000 n=6
Symbols945,172945,322+150 (+ 0.02%)~~p=0.001 n=6
Types408,068408,088+20 (+ 0.00%)~~p=0.001 n=6
Memory used1,222,022k (± 0.00%)1,222,087k (± 0.00%)+65k (+ 0.01%)1,222,005k1,222,148kp=0.037 n=6
Parse Time6.91s (± 0.53%)6.93s (± 0.49%)~6.88s6.97sp=0.420 n=6
Bind Time1.86s (± 0.40%)1.87s (± 0.52%)+0.01s (+ 0.72%)1.86s1.88sp=0.044 n=6
Check Time31.38s (± 0.34%)31.31s (± 0.29%)~31.16s31.43sp=0.261 n=6
Emit Time14.70s (± 0.53%)14.65s (± 0.56%)~14.56s14.78sp=0.261 n=6
Total Time54.86s (± 0.28%)54.76s (± 0.26%)~54.56s54.94sp=0.261 n=6
mui-docs - node (v18.15.0, x64)
Errors55~~~p=1.000 n=6
Symbols1,954,6601,954,742+82 (+ 0.00%)~~p=0.001 n=6
Types676,415676,449+34 (+ 0.01%)~~p=0.001 n=6
Memory used1,753,509k (± 0.00%)1,753,588k (± 0.00%)+78k (+ 0.00%)1,753,560k1,753,610kp=0.005 n=6
Parse Time6.89s (± 0.45%)6.86s (± 0.46%)~6.83s6.92sp=0.089 n=6
Bind Time2.32s (± 0.42%)2.32s (± 0.52%)~2.30s2.33sp=0.865 n=6
Check Time56.80s (± 0.43%)56.82s (± 0.50%)~56.45s57.23sp=1.000 n=6
Emit Time0.14s (± 5.31%)0.14s (± 4.51%)~0.13s0.15sp=0.718 n=6
Total Time66.15s (± 0.37%)66.14s (± 0.45%)~65.77s66.59sp=0.936 n=6
self-build-src - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,215,5671,215,569+2 (+ 0.00%)~~p=0.001 n=6
Types257,612257,612~~~p=1.000 n=6
Memory used2,323,373k (± 0.01%)2,323,196k (± 0.04%)~2,322,293k2,324,724kp=0.128 n=6
Parse Time5.07s (± 0.85%)5.08s (± 0.34%)~5.05s5.10sp=0.297 n=6
Bind Time1.89s (± 0.97%)1.88s (± 0.95%)~1.85s1.90sp=0.625 n=6
Check Time33.98s (± 0.13%)34.12s (± 0.38%)+0.14s (+ 0.40%)33.92s34.28sp=0.045 n=6
Emit Time2.59s (± 1.68%)2.60s (± 2.51%)~2.50s2.70sp=0.936 n=6
Total Time43.56s (± 0.15%)43.68s (± 0.26%)~43.55s43.82sp=0.109 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,215,5671,215,569+2 (+ 0.00%)~~p=0.001 n=6
Types257,612257,612~~~p=1.000 n=6
Memory used2,397,818k (± 0.03%)2,397,787k (± 0.01%)~2,397,507k2,398,149kp=0.378 n=6
Parse Time6.31s (± 0.93%)6.29s (± 0.41%)~6.25s6.32sp=0.688 n=6
Bind Time2.03s (± 1.16%)2.03s (± 0.54%)~2.02s2.05sp=0.744 n=6
Check Time40.63s (± 0.13%)40.79s (± 0.16%)+0.17s (+ 0.42%)40.70s40.87sp=0.008 n=6
Emit Time3.10s (± 2.43%)3.12s (± 1.08%)~3.07s3.16sp=0.810 n=6
Total Time52.09s (± 0.24%)52.24s (± 0.19%)~52.11s52.38sp=0.066 n=6
self-compiler - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols256,196256,198+2 (+ 0.00%)~~p=0.001 n=6
Types103,640103,640~~~p=1.000 n=6
Memory used424,229k (± 0.01%)424,200k (± 0.02%)~424,120k424,317kp=0.173 n=6
Parse Time4.35s (± 0.56%)4.33s (± 0.64%)~4.30s4.38sp=0.191 n=6
Bind Time1.61s (± 0.68%)1.59s (± 1.26%)~1.57s1.62sp=0.087 n=6
Check Time22.53s (± 0.24%)22.58s (± 0.35%)~22.49s22.71sp=0.378 n=6
Emit Time1.71s (± 0.86%)1.71s (± 1.13%)~1.68s1.73sp=0.870 n=6
Total Time30.20s (± 0.13%)30.21s (± 0.25%)~30.15s30.36sp=0.747 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors3535~~~p=1.000 n=6
Symbols224,824224,824~~~p=1.000 n=6
Types93,39093,390~~~p=1.000 n=6
Memory used369,315k (± 0.02%)369,449k (± 0.04%)+133k (+ 0.04%)369,319k369,707kp=0.031 n=6
Parse Time2.95s (± 0.97%)2.95s (± 1.08%)~2.89s2.98sp=1.000 n=6
Bind Time1.58s (± 0.93%)1.57s (± 0.74%)~1.56s1.59sp=0.251 n=6
Check Time15.68s (± 0.38%)15.67s (± 0.20%)~15.63s15.72sp=1.000 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time20.21s (± 0.29%)20.19s (± 0.14%)~20.16s20.23sp=0.572 n=6
vscode - node (v18.15.0, x64)
Errors44~~~p=1.000 n=6
Symbols2,797,3132,797,317+4 (+ 0.00%)~~p=0.001 n=6
Types950,092950,094+2 (+ 0.00%)~~p=0.001 n=6
Memory used2,925,378k (± 0.00%)2,925,421k (± 0.00%)~2,925,293k2,925,523kp=0.298 n=6
Parse Time16.63s (± 0.24%)16.63s (± 0.29%)~16.59s16.72sp=0.872 n=6
Bind Time4.97s (± 0.50%)4.96s (± 0.35%)~4.93s4.98sp=0.627 n=6
Check Time88.73s (± 0.41%)88.64s (± 0.25%)~88.33s88.98sp=1.000 n=6
Emit Time24.72s (± 7.33%)24.67s (± 7.94%)~23.68s28.66sp=0.630 n=6
Total Time135.05s (± 1.59%)134.91s (± 1.37%)~133.97s138.67sp=0.936 n=6
webpack - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols265,853265,858+5 (+ 0.00%)~~p=0.001 n=6
Types108,438108,442+4 (+ 0.00%)~~p=0.001 n=6
Memory used410,406k (± 0.02%)410,396k (± 0.03%)~410,293k410,532kp=0.936 n=6
Parse Time4.87s (± 0.71%)4.88s (± 0.96%)~4.80s4.94sp=0.687 n=6
Bind Time2.07s (± 1.13%)2.07s (± 0.66%)~2.05s2.08sp=0.357 n=6
Check Time21.11s (± 0.48%)21.08s (± 0.45%)~20.99s21.23sp=0.521 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time28.06s (± 0.40%)28.03s (± 0.22%)~27.97s28.12sp=1.000 n=6
xstate-main - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols523,981524,146+165 (+ 0.03%)~~p=0.001 n=6
Types178,708178,732+24 (+ 0.01%)~~p=0.001 n=6
Memory used461,202k (± 0.02%)461,282k (± 0.02%)~461,201k461,470kp=0.230 n=6
Parse Time3.24s (± 0.80%)3.24s (± 0.37%)~3.22s3.25sp=0.935 n=6
Bind Time1.18s (± 0.64%)1.18s (± 0.44%)~1.18s1.19sp=0.784 n=6
Check Time18.15s (± 0.37%)18.19s (± 0.46%)~18.08s18.27sp=0.334 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time22.57s (± 0.30%)22.61s (± 0.36%)~22.50s22.68sp=0.377 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)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

Developer Information:

Download Benchmarks

@adrian-gierakowski

Copy link
Copy Markdown

Will this land in 5.4.x or do we need to wait for 5.5 to benefit from it? Thanks!

@Andarist

Copy link
Copy Markdown
Contributor

I doubt it. TS usually only backports fixes for recent regressions or other critical things.

You don’t have to wait till 5.5 though. Once this gets landed a nightly version will be released within 24h from the merge and you can start using it almost immediately

@typescript-bot

Copy link
Copy Markdown
Contributor

Anders Hejlsberg (@ahejlsberg) Here are the results of running the top 400 repos comparing main and refs/pull/58337/merge:

Something interesting changed - please have a look.

Details

reduxjs/redux

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

test/tsconfig.json

  • error TS2345: Argument of type '<NextExt extends {}, NextStateExt extends {}>(x: StoreEnhancerStoreCreator<NextExt, NextStateExt>) => StoreEnhancerStoreCreator<NextExt, NextStateExt>' is not assignable to parameter of type 'StoreEnhancer<Store<Todo[], TodoAction, unknown>, {}>'.

@mikearnaldi

Copy link
Copy Markdown

Ok, now it fixes the Effect repro. Sorry for the confusion.

Thank you immensely!! This makes a lot of difference for Effect, I will test this tomorrow just to double check that in the large codebase nothing wierd happens.

I can confirm that all seems to work fine!

@jakebailey

Copy link
Copy Markdown
Member

Looking at the breaks, the webpack one does look like a preexisting circularity, but the redux example doesn't look like one. Any clue what's going on there?

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.

Looks like we're generalizing a mechanism we already used for this issue in variance annotations to signature resolution (and handling the nested calls better by using ??= instead of = at the cache assignments). Seems OK, but maybe we should abstract this concept into a helper like doOutsideOfCurrentResolutionContext so it's easier to apply to more entrypoints as-needed? Part of me doubts that signature resolution and variance annotations are the only two places we'd ultimately like to start checking "from the top" regardless of entrypoint (class base type calculations? decorator resolution? apparent member lookup?).

@ahejlsberg

Copy link
Copy Markdown
MemberAuthor

Jake Bailey (@jakebailey) See my comment about the Redux change here.

@jakebailey

Copy link
Copy Markdown
Member

Oops, missed both in the comment noise, though I can't say I see what the circularity is in that particular line...

@ahejlsberg

Anders Hejlsberg (ahejlsberg) commented Apr 29, 2024

Copy link
Copy Markdown
MemberAuthor

Seems OK, but maybe we should abstract this concept into a helper like doOutsideOfCurrentResolutionContext...

Hmm, not so sure about that. We have just two places where we do it and all that needs to be saved/restored is the resolutionStart variable. Also, the saving/restoring is conditional, so doesn't lend itself all that well to a function with a callback. But even more importantly, anyone doing this becomes responsible for stopping infinite recursion by some other mechanism. That's what's happening in variance computation and signature resolution, but the techniques are bespoke to each scenario.

@ahejlsberg

Copy link
Copy Markdown
MemberAuthor

Oops, missed both in the comment noise, though I can't say I see what the circularity is in that particular line...

I'm not sure, but it's really an orthogonal issue. It was an error before as well, just not consistently so. If there's something we can do to not make it an error, then that's probably a different feature request.

@ssalbdivad

David Blass (ssalbdivad) commented Jun 7, 2024

Copy link
Copy Markdown

So with some help from Mateusz Burzyński (@Andarist) and Jake Bailey (@jakebailey), it seems likely it was this change that was responsible for the performance hit in https://github.com/arktypeio/arktype?

{"checkTime": 9.68,"types": 483415,"instantiations": 2629152}
devDependencies:
-typescript5.5.0-dev.20240429+typescript5.5.0-dev.20240430{"checkTime": 12.2,"types": 514846,"instantiations": 2819487}

(I had previously incorrectly attributed it to #58372)

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.

TypeScript Language Server False Positive Error Reporting Incorrect ts7022 error emitted by tsserver (not by tsc)

9 participants

@ahejlsberg@typescript-bot@jakebailey@DanielRosenwasser@Andarist@mikearnaldi@adrian-gierakowski@ssalbdivad@weswigham