Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make catch clause checking consistent with variable declarations #52240

Merged
merged 8 commits into from
Jan 19, 2023

Conversation

jakebailey
Copy link
Member

@jakebailey jakebailey commented Jan 14, 2023

Fixes #47383

This changes our handling of catch clauses to work just like other variable declarations (by using the same code!), with the exception that:

  • You can only annotate the variable declaration with any or unknown. This is the same as before.
  • If you don't annotate it, we treat it as an implicit annotation of any or unknown depending on useUnknownInCatchVariables.
    • This is new; previously, the code for catch clause typing was in a totally different place which caused all destructured values to have the same type depending on that setting (very different than regular variable declarations).
    • We treat it as having an explicit annotation because if we choose any, we don't want to see follow-on errors about implicit any within the destructured value. (Or, maybe we do? Probably not?)

Now that we check these declarations using the same code as variable declarations, we can correctly and consistently handle destructuring within catch clauses, fixing the linked issue. It also seems to fix issues I've observed in tsserver as the old error was only surfaced as a side effect (so, sometimes errors would appear thanks to semantic tokens and such).

This is a breaking change as you'll get errors on destructure if the type is unknown, but I think it's more consistent.

@jakebailey
Copy link
Member Author

@typescript-bot test this
@typescript-bot test top100
@typescript-bot user test this
@typescript-bot user test tsserver
@typescript-bot test tsserver top100
@typescript-bot run dt
@typescript-bot perf test this
@typescript-bot pack this

@jakebailey jakebailey added the Breaking Change Would introduce errors in existing code label Jan 14, 2023
@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Jan 14, 2023
@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 14, 2023

Heya @jakebailey, I've started to run the diff-based user code test suite on this PR at f877b23. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 14, 2023

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 14, 2023

Heya @jakebailey, I've started to run the diff-based top-repos suite on this PR at f877b23. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 14, 2023

Heya @jakebailey, I've started to run the extended test suite on this PR at f877b23. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 14, 2023

Heya @jakebailey, I've started to run the parallelized Definitely Typed test suite on this PR at f877b23. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 14, 2023

Heya @jakebailey, I've started to run the tarball bundle task on this PR at f877b23. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 14, 2023

Heya @jakebailey, I've started to run the diff-based top-repos suite (tsserver) on this PR at f877b23. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 14, 2023

Heya @jakebailey, I've started to run the perf test suite on this PR at f877b23. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 14, 2023

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/142678/artifacts?artifactName=tgz&fileId=0A300FC6BFE1B3017859CADCA37B509DB992C16CF2FF1068D99348EDEBE3896C02&fileName=/typescript-5.0.0-insiders.20230114.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
Copy link
Collaborator

@jakebailey Here are the results of running the user test suite comparing main and refs/pull/52240/merge:

Everything looks good!

1 similar comment
@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the user test suite comparing main and refs/pull/52240/merge:

Everything looks good!

@typescript-bot
Copy link
Collaborator

Heya @jakebailey, I've run the RWC suite on this PR - assuming you're on the TS core team, you can view the resulting diff here.

@typescript-bot
Copy link
Collaborator

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

Here they are:

Compiler

Comparison Report - main..52240
Metric main 52240 Delta Best Worst
Angular - node (v18.10.0, x64)
Memory used 358,863k (± 0.01%) 358,852k (± 0.01%) -11k (- 0.00%) 358,813k 358,882k
Parse Time 3.90s (± 0.40%) 3.92s (± 0.31%) +0.02s (+ 0.59%) 3.91s 3.94s
Bind Time 1.19s (± 1.09%) 1.19s (± 0.68%) +0.01s (+ 0.58%) 1.18s 1.20s
Check Time 8.79s (± 0.53%) 8.82s (± 0.91%) +0.03s (+ 0.32%) 8.70s 8.94s
Emit Time 7.50s (± 0.70%) 7.53s (± 0.58%) +0.03s (+ 0.43%) 7.48s 7.61s
Total Time 21.38s (± 0.48%) 21.46s (± 0.58%) +0.09s (+ 0.41%) 21.34s 21.68s
Compiler-Unions - node (v18.10.0, x64)
Memory used 194,994k (± 1.64%) 192,034k (± 0.10%) -2,960k (- 1.52%) 191,788k 192,286k
Parse Time 1.64s (± 1.69%) 1.65s (± 1.17%) +0.01s (+ 0.50%) 1.62s 1.68s
Bind Time 0.80s (± 0.56%) 0.80s (± 0.55%) -0.00s (- 0.21%) 0.80s 0.81s
Check Time 9.62s (± 1.01%) 9.61s (± 0.74%) -0.00s (- 0.03%) 9.50s 9.68s
Emit Time 2.82s (± 4.79%) 2.95s (± 5.66%) +0.13s (+ 4.54%) 2.73s 3.14s
Total Time 14.89s (± 0.48%) 15.02s (± 1.27%) +0.13s (+ 0.89%) 14.79s 15.23s
Monaco - node (v18.10.0, x64)
Memory used 345,750k (± 0.01%) 345,701k (± 0.01%) -48k (- 0.01%) 345,638k 345,733k
Parse Time 2.89s (± 0.67%) 2.93s (± 0.95%) +0.03s (+ 1.09%) 2.90s 2.97s
Bind Time 1.05s (± 0.54%) 1.06s (± 0.83%) +0.01s (+ 1.12%) 1.05s 1.07s
Check Time 7.27s (± 0.49%) 7.23s (± 0.20%) -0.03s (- 0.47%) 7.21s 7.25s
Emit Time 4.32s (± 1.07%) 4.34s (± 0.95%) +0.03s (+ 0.63%) 4.30s 4.40s
Total Time 15.53s (± 0.54%) 15.56s (± 0.44%) +0.03s (+ 0.22%) 15.49s 15.65s
TFS - node (v18.10.0, x64)
Memory used 300,537k (± 0.01%) 300,531k (± 0.00%) -6k (- 0.00%) 300,518k 300,546k
Parse Time 2.25s (± 1.82%) 2.22s (± 1.32%) -0.02s (- 1.08%) 2.20s 2.28s
Bind Time 1.18s (± 0.94%) 1.19s (± 0.68%) +0.01s (+ 0.46%) 1.17s 1.20s
Check Time 6.84s (± 0.61%) 6.87s (± 0.38%) +0.03s (+ 0.42%) 6.83s 6.91s
Emit Time 3.93s (± 1.11%) 3.91s (± 0.87%) -0.02s (- 0.43%) 3.86s 3.95s
Total Time 14.20s (± 0.60%) 14.19s (± 0.46%) -0.01s (- 0.04%) 14.08s 14.25s
material-ui - node (v18.10.0, x64)
Memory used 476,359k (± 0.01%) 476,362k (± 0.01%) +3k (+ 0.00%) 476,302k 476,401k
Parse Time 3.49s (± 1.29%) 3.49s (± 1.26%) +0.01s (+ 0.19%) 3.41s 3.52s
Bind Time 0.98s (± 0.94%) 0.98s (± 1.00%) +0.00s (+ 0.51%) 0.97s 1.00s
Check Time 16.98s (± 0.58%) 17.11s (± 1.12%) +0.12s (+ 0.72%) 16.86s 17.43s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 21.45s (± 0.52%) 21.59s (± 0.93%) +0.13s (+ 0.62%) 21.34s 21.94s
xstate - node (v18.10.0, x64)
Memory used 546,264k (± 0.01%) 546,265k (± 0.01%) +0k (+ 0.00%) 546,187k 546,381k
Parse Time 4.38s (± 0.62%) 4.37s (± 0.53%) -0.01s (- 0.14%) 4.34s 4.40s
Bind Time 1.71s (± 0.56%) 1.71s (± 0.87%) +0.00s (+ 0.23%) 1.69s 1.73s
Check Time 2.71s (± 0.68%) 2.71s (± 0.52%) +0.00s (+ 0.06%) 2.70s 2.74s
Emit Time 0.08s (± 0.22%) 0.08s (± 0.10%) -0.00s (- 0.07%) 0.08s 0.08s
Total Time 8.88s (± 0.46%) 8.88s (± 0.44%) +0.00s (+ 0.03%) 8.83s 8.92s
Angular - node (v16.17.1, x64)
Memory used 358,267k (± 0.01%) 358,226k (± 0.01%) -41k (- 0.01%) 358,179k 358,288k
Parse Time 4.09s (± 0.34%) 4.10s (± 0.25%) +0.01s (+ 0.17%) 4.08s 4.11s
Bind Time 1.25s (± 0.64%) 1.26s (± 0.72%) +0.00s (+ 0.33%) 1.24s 1.27s
Check Time 9.45s (± 0.26%) 9.46s (± 0.45%) +0.01s (+ 0.12%) 9.38s 9.49s
Emit Time 7.92s (± 0.25%) 7.93s (± 0.26%) +0.02s (+ 0.24%) 7.91s 7.97s
Total Time 22.71s (± 0.21%) 22.75s (± 0.16%) +0.04s (+ 0.17%) 22.68s 22.77s
Compiler-Unions - node (v16.17.1, x64)
Memory used 193,855k (± 0.03%) 194,478k (± 0.71%) +623k (+ 0.32%) 193,800k 197,314k
Parse Time 1.80s (± 1.47%) 1.81s (± 0.81%) +0.01s (+ 0.29%) 1.79s 1.83s
Bind Time 0.85s (± 0.57%) 0.85s (± 0.69%) +0.00s (+ 0.40%) 0.85s 0.86s
Check Time 10.28s (± 0.52%) 10.28s (± 0.73%) +0.00s (+ 0.02%) 10.15s 10.35s
Emit Time 3.07s (± 4.12%) 3.04s (± 1.05%) -0.03s (- 1.10%) 3.01s 3.10s
Total Time 16.00s (± 0.97%) 15.98s (± 0.55%) -0.02s (- 0.11%) 15.86s 16.08s
Monaco - node (v16.17.1, x64)
Memory used 345,100k (± 0.01%) 345,110k (± 0.01%) +10k (+ 0.00%) 345,058k 345,169k
Parse Time 3.12s (± 0.93%) 3.08s (± 0.50%) -0.03s (- 1.07%) 3.06s 3.10s
Bind Time 1.11s (± 0.46%) 1.12s (± 0.67%) +0.00s (+ 0.25%) 1.11s 1.13s
Check Time 7.88s (± 0.41%) 7.89s (± 0.17%) +0.01s (+ 0.14%) 7.86s 7.90s
Emit Time 4.54s (± 0.32%) 4.54s (± 0.73%) +0.01s (+ 0.14%) 4.52s 4.60s
Total Time 16.65s (± 0.33%) 16.63s (± 0.29%) -0.01s (- 0.08%) 16.58s 16.71s
TFS - node (v16.17.1, x64)
Memory used 299,901k (± 0.01%) 299,912k (± 0.01%) +11k (+ 0.00%) 299,889k 299,930k
Parse Time 2.45s (± 0.99%) 2.44s (± 0.87%) -0.00s (- 0.10%) 2.41s 2.47s
Bind Time 1.26s (± 0.97%) 1.28s (± 0.40%) +0.02s (+ 1.28%) 1.27s 1.28s
Check Time 7.40s (± 0.16%) 7.42s (± 0.59%) +0.03s (+ 0.39%) 7.38s 7.48s
Emit Time 4.23s (± 0.31%) 4.22s (± 0.59%) -0.01s (- 0.35%) 4.18s 4.26s
Total Time 15.33s (± 0.17%) 15.37s (± 0.50%) +0.03s (+ 0.23%) 15.30s 15.50s
material-ui - node (v16.17.1, x64)
Memory used 475,672k (± 0.01%) 475,695k (± 0.01%) +23k (+ 0.00%) 475,638k 475,721k
Parse Time 3.66s (± 0.73%) 3.65s (± 0.22%) -0.01s (- 0.15%) 3.65s 3.67s
Bind Time 1.01s (± 0.50%) 1.01s (± 0.85%) -0.00s (- 0.10%) 1.00s 1.02s
Check Time 18.04s (± 0.96%) 17.97s (± 0.32%) -0.07s (- 0.39%) 17.88s 18.04s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 22.71s (± 0.87%) 22.63s (± 0.28%) -0.08s (- 0.34%) 22.54s 22.72s
xstate - node (v16.17.1, x64)
Memory used 543,853k (± 0.01%) 543,919k (± 0.01%) +67k (+ 0.01%) 543,842k 544,033k
Parse Time 4.56s (± 0.30%) 4.57s (± 0.45%) +0.00s (+ 0.11%) 4.53s 4.59s
Bind Time 1.79s (± 0.98%) 1.79s (± 0.47%) -0.00s (- 0.15%) 1.78s 1.80s
Check Time 2.94s (± 0.41%) 2.94s (± 0.60%) +0.01s (+ 0.20%) 2.91s 2.95s
Emit Time 0.08s (± 6.48%) 0.08s (± 4.93%) 🟩-0.00s (- 3.89%) 0.08s 0.09s
Total Time 9.38s (± 0.33%) 9.38s (± 0.29%) +0.00s (+ 0.03%) 9.34s 9.41s
Angular - node (v14.15.1, x64)
Memory used 351,910k (± 0.00%) 351,914k (± 0.00%) +4k (+ 0.00%) 351,896k 351,926k
Parse Time 4.10s (± 0.39%) 4.13s (± 0.38%) +0.03s (+ 0.74%) 4.12s 4.16s
Bind Time 1.28s (± 0.83%) 1.27s (± 0.44%) -0.01s (- 0.46%) 1.26s 1.28s
Check Time 9.76s (± 0.47%) 9.79s (± 0.39%) +0.03s (+ 0.31%) 9.73s 9.83s
Emit Time 8.23s (± 0.47%) 8.24s (± 0.26%) +0.01s (+ 0.16%) 8.21s 8.27s
Total Time 23.37s (± 0.34%) 23.43s (± 0.16%) +0.06s (+ 0.27%) 23.36s 23.46s
Compiler-Unions - node (v14.15.1, x64)
Memory used 188,981k (± 0.02%) 190,044k (± 0.89%) +1,063k (+ 0.56%) 188,926k 192,282k
Parse Time 1.84s (± 0.50%) 1.84s (± 0.64%) +0.00s (+ 0.18%) 1.83s 1.86s
Bind Time 0.88s (± 0.74%) 0.88s (± 0.44%) -0.00s (- 0.19%) 0.87s 0.88s
Check Time 10.31s (± 0.82%) 10.31s (± 0.70%) -0.01s (- 0.06%) 10.23s 10.43s
Emit Time 3.14s (± 1.00%) 3.14s (± 1.02%) -0.00s (- 0.11%) 3.10s 3.19s
Total Time 16.17s (± 0.56%) 16.16s (± 0.56%) -0.01s (- 0.05%) 16.05s 16.29s
Monaco - node (v14.15.1, x64)
Memory used 339,878k (± 0.01%) 339,874k (± 0.01%) -4k (- 0.00%) 339,835k 339,909k
Parse Time 3.24s (± 0.55%) 3.24s (± 1.06%) +0.01s (+ 0.24%) 3.19s 3.29s
Bind Time 1.13s (± 0.54%) 1.13s (± 0.51%) +0.00s (+ 0.33%) 1.13s 1.14s
Check Time 8.16s (± 0.32%) 8.15s (± 0.24%) -0.01s (- 0.07%) 8.13s 8.18s
Emit Time 4.75s (± 0.53%) 4.76s (± 0.50%) +0.01s (+ 0.28%) 4.73s 4.79s
Total Time 17.27s (± 0.26%) 17.30s (± 0.22%) +0.02s (+ 0.13%) 17.23s 17.34s
TFS - node (v14.15.1, x64)
Memory used 294,796k (± 0.01%) 294,813k (± 0.01%) +17k (+ 0.01%) 294,798k 294,860k
Parse Time 2.72s (± 0.89%) 2.74s (± 0.70%) +0.02s (+ 0.70%) 2.72s 2.77s
Bind Time 1.10s (± 0.70%) 1.10s (± 0.43%) +0.00s (+ 0.20%) 1.10s 1.11s
Check Time 7.72s (± 0.45%) 7.74s (± 0.25%) +0.02s (+ 0.31%) 7.71s 7.76s
Emit Time 4.61s (± 0.77%) 4.60s (± 0.61%) -0.01s (- 0.14%) 4.57s 4.65s
Total Time 16.15s (± 0.31%) 16.19s (± 0.24%) +0.04s (+ 0.25%) 16.14s 16.25s
material-ui - node (v14.15.1, x64)
Memory used 471,146k (± 0.00%) 471,131k (± 0.00%) -15k (- 0.00%) 471,113k 471,149k
Parse Time 3.80s (± 0.89%) 3.80s (± 0.62%) +0.00s (+ 0.01%) 3.77s 3.83s
Bind Time 1.03s (± 0.61%) 1.03s (± 0.57%) -0.00s (- 0.06%) 1.02s 1.04s
Check Time 18.88s (± 0.49%) 18.92s (± 0.59%) +0.05s (+ 0.24%) 18.75s 19.02s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 23.71s (± 0.47%) 23.76s (± 0.57%) +0.05s (+ 0.21%) 23.55s 23.89s
xstate - node (v14.15.1, x64)
Memory used 532,117k (± 0.01%) 532,117k (± 0.00%) -1k (- 0.00%) 532,089k 532,151k
Parse Time 4.96s (± 0.69%) 5.01s (± 0.30%) +0.05s (+ 0.94%) 4.99s 5.03s
Bind Time 1.65s (± 1.24%) 1.66s (± 1.08%) +0.01s (+ 0.53%) 1.64s 1.69s
Check Time 3.06s (± 0.76%) 3.09s (± 0.56%) +0.03s (+ 0.83%) 3.07s 3.12s
Emit Time 0.10s (± 4.15%) 0.10s (± 0.15%) -0.00s (- 1.42%) 0.10s 0.10s
Total Time 9.78s (± 0.53%) 9.86s (± 0.27%) +0.08s (+ 0.78%) 9.83s 9.90s
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-135-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v18.10.0, x64)
  • node (v16.17.1, x64)
  • node (v14.15.1, x64)
Scenarios
  • Angular - node (v18.10.0, x64)
  • Angular - node (v16.17.1, x64)
  • Angular - node (v14.15.1, x64)
  • Compiler-Unions - node (v18.10.0, x64)
  • Compiler-Unions - node (v16.17.1, x64)
  • Compiler-Unions - node (v14.15.1, x64)
  • Monaco - node (v18.10.0, x64)
  • Monaco - node (v16.17.1, x64)
  • Monaco - node (v14.15.1, x64)
  • TFS - node (v18.10.0, x64)
  • TFS - node (v16.17.1, x64)
  • TFS - node (v14.15.1, x64)
  • material-ui - node (v18.10.0, x64)
  • material-ui - node (v16.17.1, x64)
  • material-ui - node (v14.15.1, x64)
  • xstate - node (v18.10.0, x64)
  • xstate - node (v16.17.1, x64)
  • xstate - node (v14.15.1, x64)
Benchmark Name Iterations
Current 52240 6
Baseline main 6

TSServer

Comparison Report - main..52240
Metric main 52240 Delta Best Worst
Compiler-UnionsTSServer - node (v18.10.0, x64)
Req 1 - updateOpen 2,511ms (± 5.33%) 2,398ms (± 7.69%) 🟩-112ms (- 4.47%) 2,201ms 2,602ms
Req 2 - geterr 5,313ms (± 5.39%) 5,083ms (± 8.19%) 🟩-230ms (- 4.34%) 4,664ms 5,510ms
Req 3 - references 364ms (± 5.80%) 351ms (± 8.84%) 🟩-13ms (- 3.57%) 317ms 389ms
Req 4 - navto 283ms (± 5.33%) 271ms (± 8.06%) 🟩-12ms (- 4.12%) 244ms 294ms
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) 0 ( 0.00%) 1,356 1,356
Req 5 - completionInfo 98ms (±83.88%) 97ms (±74.75%) -1ms (- 1.31%) 61ms 244ms
CompilerTSServer - node (v18.10.0, x64)
Req 1 - updateOpen 2,672ms (± 1.50%) 2,682ms (± 1.68%) +10ms (+ 0.37%) 2,641ms 2,749ms
Req 2 - geterr 3,985ms (± 0.62%) 3,987ms (± 0.57%) +2ms (+ 0.06%) 3,943ms 4,001ms
Req 3 - references 376ms (± 1.08%) 376ms (± 0.52%) +1ms (+ 0.15%) 373ms 378ms
Req 4 - navto 291ms (± 0.70%) 291ms (± 0.53%) +0ms (+ 0.04%) 288ms 293ms
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) 0 ( 0.00%) 1,518 1,518
Req 5 - completionInfo 82ms (± 1.98%) 83ms (± 2.70%) +0ms (+ 0.58%) 78ms 85ms
xstateTSServer - node (v18.10.0, x64)
Req 1 - updateOpen 3,326ms (± 0.44%) 3,347ms (± 0.73%) +21ms (+ 0.64%) 3,320ms 3,388ms
Req 2 - geterr 1,404ms (± 0.76%) 1,398ms (± 1.04%) -6ms (- 0.45%) 1,376ms 1,413ms
Req 3 - references 245ms (± 1.28%) 244ms (± 0.94%) -0ms (- 0.03%) 241ms 248ms
Req 4 - navto 357ms (± 0.47%) 360ms (± 1.36%) +3ms (+ 0.96%) 354ms 367ms
Req 5 - completionInfo count 3,159 (± 0.00%) 3,159 (± 0.00%) 0 ( 0.00%) 3,159 3,159
Req 5 - completionInfo 449ms (± 1.29%) 441ms (± 1.75%) -8ms (- 1.69%) 428ms 449ms
Compiler-UnionsTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 2,757ms (± 0.41%) 2,693ms (± 5.79%) -64ms (- 2.31%) 2,375ms 2,764ms
Req 2 - geterr 5,808ms (± 1.14%) 5,662ms (± 5.32%) -146ms (- 2.51%) 5,047ms 5,802ms
Req 3 - references 377ms (± 1.20%) 369ms (± 5.40%) -8ms (- 2.08%) 329ms 380ms
Req 4 - navto 274ms (± 1.10%) 269ms (± 5.89%) -5ms (- 1.69%) 237ms 280ms
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) 0 ( 0.00%) 1,356 1,356
Req 5 - completionInfo 298ms (± 2.14%) 293ms (± 6.05%) -5ms (- 1.70%) 258ms 308ms
CompilerTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 2,865ms (± 0.61%) 2,881ms (± 0.74%) +16ms (+ 0.58%) 2,853ms 2,905ms
Req 2 - geterr 4,314ms (± 0.52%) 4,307ms (± 0.69%) -7ms (- 0.17%) 4,249ms 4,333ms
Req 3 - references 388ms (± 0.88%) 388ms (± 1.67%) +1ms (+ 0.21%) 376ms 393ms
Req 4 - navto 299ms (± 0.30%) 300ms (± 0.73%) +0ms (+ 0.15%) 297ms 303ms
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) 0 ( 0.00%) 1,518 1,518
Req 5 - completionInfo 79ms (± 0.52%) 82ms (± 4.87%) +2ms (+ 3.15%) 79ms 90ms
xstateTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 3,449ms (± 0.96%) 3,449ms (± 0.65%) -0ms (- 0.01%) 3,420ms 3,477ms
Req 2 - geterr 1,689ms (± 3.93%) 1,687ms (± 4.51%) -3ms (- 0.15%) 1,532ms 1,724ms
Req 3 - references 134ms (±52.42%) 135ms (±49.68%) +1ms (+ 0.63%) 103ms 272ms
Req 4 - navto 342ms (± 1.55%) 341ms (± 1.93%) -0ms (- 0.15%) 329ms 348ms
Req 5 - completionInfo count 3,159 (± 0.00%) 3,159 (± 0.00%) 0 ( 0.00%) 3,159 3,159
Req 5 - completionInfo 475ms (± 3.01%) 478ms (± 2.39%) +3ms (+ 0.65%) 460ms 494ms
Compiler-UnionsTSServer - node (v14.15.1, x64)
Req 1 - updateOpen 2,852ms (± 0.55%) 2,847ms (± 0.42%) -6ms (- 0.19%) 2,833ms 2,863ms
Req 2 - geterr 6,203ms (± 0.79%) 6,163ms (± 0.64%) -40ms (- 0.65%) 6,095ms 6,211ms
Req 3 - references 389ms (± 1.48%) 388ms (± 0.95%) -1ms (- 0.13%) 382ms 392ms
Req 4 - navto 286ms (± 1.00%) 286ms (± 0.56%) -0ms (- 0.10%) 284ms 288ms
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) 0 ( 0.00%) 1,356 1,356
Req 5 - completionInfo 84ms (± 8.68%) 82ms (± 8.86%) -2ms (- 2.54%) 75ms 92ms
CompilerTSServer - node (v14.15.1, x64)
Req 1 - updateOpen 2,995ms (± 0.42%) 2,992ms (± 0.44%) -3ms (- 0.11%) 2,975ms 3,004ms
Req 2 - geterr 4,602ms (± 0.62%) 4,571ms (± 0.35%) -31ms (- 0.67%) 4,551ms 4,593ms
Req 3 - references 414ms (± 0.81%) 414ms (± 0.80%) +1ms (+ 0.14%) 412ms 419ms
Req 4 - navto 306ms (± 0.49%) 305ms (± 1.76%) -2ms (- 0.51%) 294ms 308ms
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) 0 ( 0.00%) 1,518 1,518
Req 5 - completionInfo 78ms (± 0.47%) 81ms (± 6.73%) +3ms (+ 3.79%) 77ms 90ms
xstateTSServer - node (v14.15.1, x64)
Req 1 - updateOpen 3,762ms (± 0.42%) 3,758ms (± 0.48%) -3ms (- 0.09%) 3,738ms 3,783ms
Req 2 - geterr 1,453ms (± 1.06%) 1,458ms (± 0.57%) +5ms (+ 0.37%) 1,450ms 1,472ms
Req 3 - references 124ms (± 2.04%) 126ms (± 3.21%) +2ms (+ 1.54%) 121ms 131ms
Req 4 - navto 392ms (± 0.43%) 393ms (± 0.83%) +1ms (+ 0.25%) 389ms 397ms
Req 5 - completionInfo count 3,159 (± 0.00%) 3,159 (± 0.00%) 0 ( 0.00%) 3,159 3,159
Req 5 - completionInfo 481ms (± 1.42%) 481ms (± 0.93%) -0ms (- 0.01%) 475ms 486ms
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-135-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v18.10.0, x64)
  • node (v16.17.1, x64)
  • node (v14.15.1, x64)
Scenarios
  • Compiler-UnionsTSServer - node (v18.10.0, x64)
  • Compiler-UnionsTSServer - node (v16.17.1, x64)
  • Compiler-UnionsTSServer - node (v14.15.1, x64)
  • CompilerTSServer - node (v18.10.0, x64)
  • CompilerTSServer - node (v16.17.1, x64)
  • CompilerTSServer - node (v14.15.1, x64)
  • xstateTSServer - node (v18.10.0, x64)
  • xstateTSServer - node (v16.17.1, x64)
  • xstateTSServer - node (v14.15.1, x64)
Benchmark Name Iterations
Current 52240 6
Baseline main 6

Startup

Comparison Report - main..52240
Metric main 52240 Delta Best Worst
tsc-startup - node (v16.17.1, x64)
Execution time 139.22ms (± 0.21%) 139.93ms (± 0.22%) +0.72ms (+ 0.51%) 138.76ms 142.78ms
tsserver-startup - node (v16.17.1, x64)
Execution time 230.75ms (± 0.20%) 232.06ms (± 0.20%) +1.31ms (+ 0.57%) 230.36ms 239.34ms
tsserverlibrary-startup - node (v16.17.1, x64)
Execution time 233.37ms (± 0.16%) 233.92ms (± 0.16%) +0.56ms (+ 0.24%) 232.76ms 240.29ms
typescript-startup - node (v16.17.1, x64)
Execution time 214.63ms (± 0.24%) 216.04ms (± 0.17%) +1.41ms (+ 0.65%) 214.52ms 220.60ms
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-135-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v16.17.1, x64)
Scenarios
  • tsc-startup - node (v16.17.1, x64)
  • tsserver-startup - node (v16.17.1, x64)
  • tsserverlibrary-startup - node (v16.17.1, x64)
  • typescript-startup - node (v16.17.1, x64)
Benchmark Name Iterations
Current 52240 6
Baseline main 6

Developer Information:

Download Benchmark

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the top-repos suite comparing main and refs/pull/52240/merge:

Something interesting changed - please have a look.

Details

jhipster/generator-jhipster

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

tsconfig.json

@jakebailey
Copy link
Member Author

jakebailey commented Jan 14, 2023

Also, with this change in place, it would be really, really easy to allow arbitrary type annotations on catch clauses.

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the top-repos suite comparing main and refs/pull/52240/merge:

Something interesting changed - please have a look.

Details

felixrieseberg/windows95

⚠️ Note that built also had errors ⚠️
Req #241 - references
    at formatMessage2 (/typescript-main/built/local/tsserver.js:174244:21)
    at IOSession.writeMessage (/typescript-main/built/local/tsserver.js:175518:21)
    at IOSession.send (/typescript-main/built/local/tsserver.js:175515:10)
    at IOSession.doOutput (/typescript-main/built/local/tsserver.js:175571:10)
    at IOSession.onMessage (/typescript-main/built/local/tsserver.js:177349:14)
    at Interface.<anonymous> (/typescript-main/built/local/tsserver.js:178787:14)
Req #241 - references
    at formatMessage2 (/typescript-52240/built/local/tsserver.js:174238:21)
    at IOSession.writeMessage (/typescript-52240/built/local/tsserver.js:175512:21)
    at IOSession.send (/typescript-52240/built/local/tsserver.js:175509:10)
    at IOSession.doOutput (/typescript-52240/built/local/tsserver.js:175565:10)
    at IOSession.onMessage (/typescript-52240/built/local/tsserver.js:177343:14)
    at Interface.<anonymous> (/typescript-52240/built/local/tsserver.js:178781:14)

That is a filtered view of the text. To see the raw error text, go to RepoResults4/felixrieseberg.windows95.rawError.txt in the artifact folder

Last few requests

{"seq":238,"type":"request","command":"completionEntryDetails","arguments":{"file":"@PROJECT_ROOT@/src/renderer/lib/_libwabt.js","line":13,"offset":1850,"entryNames":["_"]}}
{"seq":239,"type":"request","command":"completionInfo","arguments":{"file":"@PROJECT_ROOT@/src/renderer/lib/_libwabt.js","line":13,"offset":2236,"includeExternalModuleExports":false,"includeInsertTextCompletions":true,"triggerKind":1}}
{"seq":240,"type":"request","command":"completionEntryDetails","arguments":{"file":"@PROJECT_ROOT@/src/renderer/lib/_libwabt.js","line":13,"offset":2236,"entryNames":["_"]}}
{"seq":241,"type":"request","command":"references","arguments":{"file":"@PROJECT_ROOT@/src/renderer/lib/_libwabt.js","line":13,"offset":2453}}

Repro Steps

  1. git clone https://github.com/felixrieseberg/windows95 --recurse-submodules
  2. In dir windows95, run git reset --hard 17a81393467e2668eb2eea291ab4b6a749756dad
  3. Back in the initial folder, download RepoResults4/felixrieseberg.windows95.replay.txt from the artifact folder
  4. npm install --no-save @typescript/server-replay
  5. npx tsreplay ./windows95 ./felixrieseberg.windows95.replay.txt path/to/tsserver.js
  6. npx tsreplay --help to learn about helpful switches for debugging, logging, etc

palantir/blueprint

⚠️ Note that built also had errors ⚠️
Req #12556 - references
    at formatMessage2 (/typescript-main/built/local/tsserver.js:174244:21)
    at IOSession.writeMessage (/typescript-main/built/local/tsserver.js:175518:21)
    at IOSession.send (/typescript-main/built/local/tsserver.js:175515:10)
    at IOSession.doOutput (/typescript-main/built/local/tsserver.js:175571:10)
    at IOSession.onMessage (/typescript-main/built/local/tsserver.js:177349:14)
    at Interface.<anonymous> (/typescript-main/built/local/tsserver.js:178787:14)
Req #12556 - references
    at formatMessage2 (/typescript-52240/built/local/tsserver.js:174238:21)
    at IOSession.writeMessage (/typescript-52240/built/local/tsserver.js:175512:21)
    at IOSession.send (/typescript-52240/built/local/tsserver.js:175509:10)
    at IOSession.doOutput (/typescript-52240/built/local/tsserver.js:175565:10)
    at IOSession.onMessage (/typescript-52240/built/local/tsserver.js:177343:14)
    at Interface.<anonymous> (/typescript-52240/built/local/tsserver.js:178781:14)

That is a filtered view of the text. To see the raw error text, go to RepoResults4/palantir.blueprint.rawError.txt in the artifact folder

Last few requests

{"seq":12553,"type":"request","command":"completionInfo","arguments":{"file":"@PROJECT_ROOT@/site/docs/versions/1/docs-app.js","line":1,"offset":280799,"includeExternalModuleExports":false,"includeInsertTextCompletions":true,"triggerKind":1}}
{"seq":12554,"type":"request","command":"completionInfo","arguments":{"file":"@PROJECT_ROOT@/site/docs/versions/1/docs-app.js","line":1,"offset":281409,"includeExternalModuleExports":false,"includeInsertTextCompletions":true,"triggerKind":1}}
{"seq":12555,"type":"request","command":"completionEntryDetails","arguments":{"file":"@PROJECT_ROOT@/site/docs/versions/1/docs-app.js","line":1,"offset":281409,"entryNames":["arguments"]}}
{"seq":12556,"type":"request","command":"references","arguments":{"file":"@PROJECT_ROOT@/site/docs/versions/1/docs-app.js","line":1,"offset":281960}}

Repro Steps

  1. git clone https://github.com/palantir/blueprint --recurse-submodules
  2. In dir blueprint, run git reset --hard febdf73d3a3e6f7e850c3cbdd271a3f28b645a87
  3. In dir blueprint, run yarn install --ignore-engines --ignore-scripts --silent
  4. Back in the initial folder, download RepoResults4/palantir.blueprint.replay.txt from the artifact folder
  5. npm install --no-save @typescript/server-replay
  6. npx tsreplay ./blueprint ./palantir.blueprint.replay.txt path/to/tsserver.js
  7. npx tsreplay --help to learn about helpful switches for debugging, logging, etc

vercel/hyper

⚠️ Note that built also had errors ⚠️
Req #12511 - references
    at formatMessage2 (/typescript-main/built/local/tsserver.js:174244:21)
    at IOSession.writeMessage (/typescript-main/built/local/tsserver.js:175518:21)
    at IOSession.send (/typescript-main/built/local/tsserver.js:175515:10)
    at IOSession.doOutput (/typescript-main/built/local/tsserver.js:175571:10)
    at IOSession.onMessage (/typescript-main/built/local/tsserver.js:177349:14)
    at Interface.<anonymous> (/typescript-main/built/local/tsserver.js:178787:14)
Req #12511 - references
    at formatMessage2 (/typescript-52240/built/local/tsserver.js:174238:21)
    at IOSession.writeMessage (/typescript-52240/built/local/tsserver.js:175512:21)
    at IOSession.send (/typescript-52240/built/local/tsserver.js:175509:10)
    at IOSession.doOutput (/typescript-52240/built/local/tsserver.js:175565:10)
    at IOSession.onMessage (/typescript-52240/built/local/tsserver.js:177343:14)
    at Interface.<anonymous> (/typescript-52240/built/local/tsserver.js:178781:14)

That is a filtered view of the text. To see the raw error text, go to RepoResults1/vercel.hyper.rawError.txt in the artifact folder

Last few requests

{"seq":12508,"type":"request","command":"completionInfo","arguments":{"file":"@PROJECT_ROOT@/bin/yarn-standalone.js","line":84971,"offset":33155,"includeExternalModuleExports":false,"includeInsertTextCompletions":true,"triggerKind":2,"triggerCharacter":"."}}
{"seq":12509,"type":"request","command":"completionInfo","arguments":{"file":"@PROJECT_ROOT@/bin/yarn-standalone.js","line":84971,"offset":33562,"includeExternalModuleExports":false,"includeInsertTextCompletions":true,"triggerKind":2,"triggerCharacter":"\""}}
{"seq":12510,"type":"request","command":"completionInfo","arguments":{"file":"@PROJECT_ROOT@/bin/yarn-standalone.js","line":84971,"offset":33907,"includeExternalModuleExports":false,"includeInsertTextCompletions":true,"triggerKind":1}}
{"seq":12511,"type":"request","command":"references","arguments":{"file":"@PROJECT_ROOT@/bin/yarn-standalone.js","line":84971,"offset":34111}}

Repro Steps

  1. git clone https://github.com/vercel/hyper --recurse-submodules
  2. In dir hyper, run git reset --hard 68446541d05c2595036411634792d8b874217647
  3. Install packages (exact steps are below, but it might be easier to follow the repo readme)
    1. In dir hyper/app, run yarn install --ignore-engines --ignore-scripts --silent
    2. In dir hyper, run yarn install --ignore-engines --ignore-scripts --silent
  4. Back in the initial folder, download RepoResults1/vercel.hyper.replay.txt from the artifact folder
  5. npm install --no-save @typescript/server-replay
  6. npx tsreplay ./hyper ./vercel.hyper.replay.txt path/to/tsserver.js
  7. npx tsreplay --help to learn about helpful switches for debugging, logging, etc

@jakebailey jakebailey changed the title Treat catch clauses the same as other variable declarations Make catch clause checking consistent with variable declarations Jan 14, 2023
// These are okay with useUnknownInCatchVariables=false, but not okay with useUnknownInCatchVariables=true.
try {} catch ({ x }) { x }
~
!!! error TS2339: Property 'x' does not exist on type '{}'.
Copy link
Member Author

@jakebailey jakebailey Jan 14, 2023

Choose a reason for hiding this comment

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

These kinds of errors happen in strictNullChecks=false because destructuring an object uses the apparent type, and the apparent type of unknown in strictNullChecks=false is {}. See #47494.

I can't say I like these errors (especially given the errors for destructuring an array actually do mention unknown), but I feel like the likelihood of someone enabling useUnknownInCatchVariables but not enabling strictNullChecks is very low, as is having strictNullChecks disabled and explicitly annotating with : unknown.

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

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

Look good, although I don't know what the change to control flow does.

@@ -27079,6 +27078,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
isFunctionLike(node) && !getImmediatelyInvokedFunctionExpression(node) ||
node.kind === SyntaxKind.ModuleBlock ||
node.kind === SyntaxKind.SourceFile ||
node.kind === SyntaxKind.CatchClause ||
Copy link
Member

Choose a reason for hiding this comment

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

why is this needed? How much does it increase the tree-walking that control flow analysis does?

Copy link
Member Author

@jakebailey jakebailey Jan 19, 2023

Choose a reason for hiding this comment

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

Right now, this code is wrong for catch clauses because it doesn't stop at the CatchClause (where the catch clause variable declaration is scoped) and goes to the try/catch's enclosing scope.

Then, it determines that the catch clause variable is not yet defined (because it's checking the wrong scope!), but then because we only allow any or unknown, assumeInitialized turns into true, saving the day.

I noticed this on the PR where I allowed arbitrary annotations because this code path happens to be called by semantic tokens and causes errors that persist in tsserver (yet do not show in tests!); I cherry-picked it even though it's not strictly required because 1) it's definitely wrong, and 2) it's faster to skip all of the work if we know it's a catch clause variable.

Copy link
Member Author

Choose a reason for hiding this comment

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

(Half-related, but I swear I read code during working on this PR that looked the same as this code but was correct; I can't remember where anymore...)

Copy link
Member

Choose a reason for hiding this comment

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

faster is good 👍🏼

Copy link
Member Author

@jakebailey jakebailey Jan 19, 2023

Choose a reason for hiding this comment

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

I think it could be faster, even; assumeInitialized is a huge expression and I think a bit of work could be skipped if some of the more simple conditions were true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team Breaking Change Would introduce errors in existing code For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Destructuring of unknown catch variable is not an error
3 participants