Skip to content

Add nested call and new expressions as potential intra expression inference sites #54183

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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

Andarist
Copy link
Contributor

@Andarist Andarist commented May 8, 2023

Sometimes nested generic functions are skipped during inference in the first pass:
https://github.dev/microsoft/TypeScript/blob/04d4580f4eedc036b014ef4329cffe9979da3af9/src/compiler/checker.ts#L33619-L33634

However, those calls are resolved from within checkExpressionWithContextualType and by the time we have a chance to call addIntraExpressionInferenceSite they are already resolved. So it, imho, makes sense to actually use them as intra expression inference sites.

fixes #54184
fixes #52114
fixes #53776

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label May 8, 2023
@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

@sandersn sandersn requested a review from ahejlsberg May 22, 2023 23:09
@typescript-bot typescript-bot added For Backlog Bug PRs that fix a backlog bug and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels May 22, 2023
@sandersn sandersn requested a review from weswigham May 22, 2023 23:09
@weswigham
Copy link
Member

@typescript-bot test this
@typescript-bot run dt
@typescript-bot test top100
@typescript-bot perf test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 24, 2023

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 24, 2023

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 24, 2023

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 24, 2023

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

Copy link
Member

@weswigham weswigham left a comment

Choose a reason for hiding this comment

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

This seems fine - iirc, needing to do a deeper traversal for context-sensitivity checking was something we've known for awhile, we've just been avoiding doing it in most of our other fixes, since we've been worried about the perf cost of a deeper tree traversal. Assuming perf comes back fine, only change I think I'd want is a deprecated isContextSensitive in the public API (which can just call the new function), so this isn't a hard API break.

@typescript-bot
Copy link
Collaborator

Heya @weswigham, 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

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

Everything looks good!

@typescript-bot
Copy link
Collaborator

Hey @weswigham, the results of running the DT tests are ready.
Everything looks the same!
You can check the log here.

…inference-with-resolved-calls

# Conflicts:
#	src/compiler/checker.ts
#	tests/baselines/reference/intraExpressionInferences.errors.txt
#	tests/baselines/reference/intraExpressionInferences.js
#	tests/baselines/reference/intraExpressionInferences.symbols
#	tests/baselines/reference/intraExpressionInferences.types
#	tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferences.ts
@Andarist
Copy link
Contributor Author

only change I think I'd want is a deprecated isContextSensitive in the public API (which can just call the new function), so this isn't a hard API break.

is this relevant for a function that is annotated with /** @internal */?

@typescript-bot
Copy link
Collaborator

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

Here they are:

Compiler

Comparison Report - main..54183
Metric main 54183 Delta Best Worst p-value
Angular - node (v18.10.0, x64)
Memory used 365,796k (± 0.01%) 365,968k (± 0.00%) +172k (+ 0.05%) 365,947k 365,988k p=0.005 n=6
Parse Time 3.43s (± 0.57%) 3.41s (± 0.70%) ~ 3.37s 3.43s p=0.286 n=6
Bind Time 1.11s (± 0.73%) 1.11s (± 0.46%) ~ 1.11s 1.12s p=0.929 n=6
Check Time 8.74s (± 0.30%) 8.74s (± 0.33%) ~ 8.70s 8.78s p=0.629 n=6
Emit Time 7.44s (± 0.24%) 7.43s (± 0.45%) ~ 7.38s 7.47s p=0.934 n=6
Total Time 20.73s (± 0.21%) 20.69s (± 0.29%) ~ 20.61s 20.76s p=0.336 n=6
Compiler-Unions - node (v18.10.0, x64)
Memory used 193,058k (± 1.50%) 192,000k (± 1.24%) ~ 190,998k 196,871k p=0.066 n=6
Parse Time 1.50s (± 1.40%) 1.50s (± 1.15%) ~ 1.47s 1.52s p=0.807 n=6
Bind Time 0.77s (± 0.00%) 0.77s (± 0.00%) ~ 0.77s 0.77s p=1.000 n=6
Check Time 9.49s (± 0.42%) 9.63s (± 0.44%) +0.14s (+ 1.47%) 9.59s 9.69s p=0.005 n=6
Emit Time 2.73s (± 0.64%) 2.75s (± 0.84%) ~ 2.72s 2.78s p=0.225 n=6
Total Time 14.50s (± 0.42%) 14.65s (± 0.26%) +0.15s (+ 1.03%) 14.59s 14.70s p=0.006 n=6
Monaco - node (v18.10.0, x64)
Memory used 346,604k (± 0.01%) 346,562k (± 0.00%) -42k (- 0.01%) 346,550k 346,576k p=0.013 n=6
Parse Time 2.60s (± 1.41%) 2.58s (± 1.26%) ~ 2.54s 2.63s p=0.464 n=6
Bind Time 1.00s (± 0.81%) 1.01s (± 0.83%) ~ 1.00s 1.02s p=0.673 n=6
Check Time 7.14s (± 0.43%) 7.18s (± 0.26%) ~ 7.16s 7.21s p=0.086 n=6
Emit Time 4.25s (± 0.33%) 4.26s (± 1.02%) ~ 4.21s 4.32s p=0.808 n=6
Total Time 14.99s (± 0.20%) 15.02s (± 0.49%) ~ 14.93s 15.13s p=0.630 n=6
TFS - node (v18.10.0, x64)
Memory used 300,604k (± 0.00%) 300,763k (± 0.01%) +159k (+ 0.05%) 300,735k 300,794k p=0.005 n=6
Parse Time 2.06s (± 1.12%) 2.06s (± 1.05%) ~ 2.02s 2.08s p=0.788 n=6
Bind Time 1.14s (± 0.73%) 1.14s (± 0.86%) ~ 1.12s 1.15s p=0.340 n=6
Check Time 6.62s (± 0.74%) 6.63s (± 0.66%) ~ 6.56s 6.69s p=0.872 n=6
Emit Time 3.87s (± 0.93%) 3.88s (± 0.53%) ~ 3.85s 3.91s p=0.421 n=6
Total Time 13.70s (± 0.40%) 13.72s (± 0.40%) ~ 13.65s 13.78s p=0.376 n=6
material-ui - node (v18.10.0, x64)
Memory used 481,752k (± 0.01%) 482,344k (± 0.01%) +592k (+ 0.12%) 482,285k 482,377k p=0.005 n=6
Parse Time 3.10s (± 0.44%) 3.12s (± 0.72%) ~ 3.10s 3.16s p=0.101 n=6
Bind Time 0.92s (± 1.66%) 0.91s (± 0.56%) ~ 0.91s 0.92s p=1.000 n=6
Check Time 16.78s (± 0.41%) 16.95s (± 0.56%) +0.17s (+ 1.02%) 16.83s 17.07s p=0.010 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 20.80s (± 0.39%) 20.99s (± 0.47%) +0.19s (+ 0.89%) 20.85s 21.12s p=0.013 n=6
xstate - node (v18.10.0, x64)
Memory used 563,021k (± 0.02%) 562,733k (± 0.02%) -289k (- 0.05%) 562,621k 562,918k p=0.008 n=6
Parse Time 3.82s (± 0.46%) 3.85s (± 0.67%) ~ 3.81s 3.87s p=0.106 n=6
Bind Time 1.63s (± 0.63%) 1.63s (± 0.34%) ~ 1.62s 1.63s p=0.663 n=6
Check Time 2.82s (± 0.77%) 2.82s (± 0.85%) ~ 2.80s 2.86s p=0.936 n=6
Emit Time 0.08s (± 0.00%) 0.08s (± 0.00%) ~ 0.08s 0.08s p=1.000 n=6
Total Time 8.35s (± 0.40%) 8.37s (± 0.58%) ~ 8.32s 8.44s p=0.520 n=6
Angular - node (v16.17.1, x64)
Memory used 365,269k (± 0.00%) 365,327k (± 0.01%) ~ 365,247k 365,377k p=0.066 n=6
Parse Time 3.58s (± 0.73%) 3.54s (± 0.55%) -0.04s (- 1.07%) 3.52s 3.57s p=0.030 n=6
Bind Time 1.19s (± 0.69%) 1.17s (± 0.44%) -0.01s (- 1.12%) 1.17s 1.18s p=0.014 n=6
Check Time 9.61s (± 0.31%) 9.58s (± 0.39%) ~ 9.53s 9.63s p=0.199 n=6
Emit Time 7.99s (± 0.82%) 7.92s (± 0.58%) -0.07s (- 0.94%) 7.87s 8.00s p=0.044 n=6
Total Time 22.36s (± 0.21%) 22.21s (± 0.42%) -0.16s (- 0.69%) 22.10s 22.37s p=0.016 n=6
Compiler-Unions - node (v16.17.1, x64)
Memory used 192,883k (± 0.03%) 193,224k (± 0.53%) ~ 192,742k 195,332k p=0.230 n=6
Parse Time 1.59s (± 0.76%) 1.59s (± 1.52%) ~ 1.55s 1.62s p=0.744 n=6
Bind Time 0.83s (± 0.49%) 0.83s (± 0.66%) ~ 0.82s 0.83s p=0.282 n=6
Check Time 10.25s (± 0.53%) 10.31s (± 0.29%) ~ 10.26s 10.34s p=0.053 n=6
Emit Time 3.00s (± 0.70%) 3.05s (± 1.46%) +0.05s (+ 1.72%) 3.01s 3.13s p=0.030 n=6
Total Time 15.67s (± 0.40%) 15.78s (± 0.35%) +0.12s (+ 0.73%) 15.68s 15.83s p=0.020 n=6
Monaco - node (v16.17.1, x64)
Memory used 345,874k (± 0.00%) 345,862k (± 0.00%) ~ 345,854k 345,870k p=0.297 n=6
Parse Time 2.73s (± 0.38%) 2.72s (± 0.28%) -0.01s (- 0.49%) 2.71s 2.73s p=0.046 n=6
Bind Time 1.09s (± 0.75%) 1.09s (± 0.00%) ~ 1.09s 1.09s p=0.290 n=6
Check Time 7.83s (± 0.33%) 7.90s (± 0.37%) +0.07s (+ 0.89%) 7.86s 7.94s p=0.008 n=6
Emit Time 4.46s (± 1.15%) 4.50s (± 0.81%) ~ 4.45s 4.54s p=0.198 n=6
Total Time 16.11s (± 0.45%) 16.21s (± 0.36%) +0.10s (+ 0.64%) 16.14s 16.29s p=0.037 n=6
TFS - node (v16.17.1, x64)
Memory used 299,938k (± 0.01%) 300,109k (± 0.00%) +171k (+ 0.06%) 300,097k 300,131k p=0.005 n=6
Parse Time 2.16s (± 0.48%) 2.16s (± 0.59%) ~ 2.14s 2.17s p=0.868 n=6
Bind Time 1.24s (± 0.99%) 1.24s (± 0.61%) ~ 1.23s 1.25s p=0.388 n=6
Check Time 7.26s (± 0.46%) 7.32s (± 0.37%) +0.05s (+ 0.71%) 7.28s 7.35s p=0.020 n=6
Emit Time 4.33s (± 0.66%) 4.40s (± 0.44%) +0.07s (+ 1.54%) 4.38s 4.43s p=0.005 n=6
Total Time 15.00s (± 0.40%) 15.11s (± 0.20%) +0.12s (+ 0.78%) 15.06s 15.15s p=0.005 n=6
material-ui - node (v16.17.1, x64)
Memory used 480,973k (± 0.01%) 481,627k (± 0.01%) +653k (+ 0.14%) 481,560k 481,705k p=0.005 n=6
Parse Time 3.28s (± 1.34%) 3.24s (± 0.28%) ~ 3.23s 3.25s p=0.061 n=6
Bind Time 0.95s (± 1.59%) 0.94s (± 0.55%) ~ 0.93s 0.94s p=0.242 n=6
Check Time 18.03s (± 1.20%) 17.95s (± 0.79%) ~ 17.78s 18.17s p=0.575 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 22.25s (± 0.99%) 22.13s (± 0.66%) ~ 21.95s 22.36s p=0.336 n=6
xstate - node (v16.17.1, x64)
Memory used 560,656k (± 0.01%) 560,513k (± 0.03%) ~ 560,321k 560,822k p=0.066 n=6
Parse Time 4.00s (± 0.41%) 4.00s (± 0.21%) ~ 3.99s 4.01s p=0.731 n=6
Bind Time 1.77s (± 0.50%) 1.76s (± 0.36%) ~ 1.75s 1.77s p=0.070 n=6
Check Time 3.06s (± 0.56%) 3.06s (± 0.68%) ~ 3.03s 3.09s p=0.809 n=6
Emit Time 0.09s (± 0.00%) 0.09s (± 0.00%) ~ 0.09s 0.09s p=1.000 n=6
Total Time 8.92s (± 0.36%) 8.92s (± 0.28%) ~ 8.87s 8.94s p=0.746 n=6
Angular - node (v14.21.3, x64)
Memory used 359,205k (± 0.01%) 359,413k (± 0.00%) +208k (+ 0.06%) 359,385k 359,435k p=0.005 n=6
Parse Time 3.68s (± 0.63%) 3.67s (± 0.28%) ~ 3.65s 3.68s p=0.220 n=6
Bind Time 1.22s (± 0.42%) 1.22s (± 0.42%) ~ 1.21s 1.22s p=1.000 n=6
Check Time 10.01s (± 0.79%) 10.05s (± 0.49%) ~ 9.99s 10.11s p=0.336 n=6
Emit Time 8.33s (± 0.94%) 8.30s (± 0.87%) ~ 8.23s 8.40s p=0.574 n=6
Total Time 23.24s (± 0.68%) 23.23s (± 0.46%) ~ 23.12s 23.40s p=0.810 n=6
Compiler-Unions - node (v14.21.3, x64)
Memory used 188,287k (± 0.01%) 188,145k (± 0.01%) -143k (- 0.08%) 188,114k 188,164k p=0.005 n=6
Parse Time 1.62s (± 0.72%) 1.61s (± 1.11%) ~ 1.59s 1.64s p=0.192 n=6
Bind Time 0.85s (± 0.74%) 0.85s (± 0.89%) ~ 0.84s 0.86s p=0.718 n=6
Check Time 10.30s (± 0.70%) 10.42s (± 0.64%) +0.11s (+ 1.08%) 10.34s 10.53s p=0.036 n=6
Emit Time 3.13s (± 0.90%) 3.16s (± 0.87%) ~ 3.13s 3.21s p=0.192 n=6
Total Time 15.91s (± 0.54%) 16.04s (± 0.39%) +0.12s (+ 0.76%) 15.93s 16.11s p=0.019 n=6
Monaco - node (v14.21.3, x64)
Memory used 341,023k (± 0.00%) 340,935k (± 0.00%) -88k (- 0.03%) 340,914k 340,954k p=0.005 n=6
Parse Time 2.82s (± 0.72%) 2.79s (± 0.37%) -0.03s (- 0.95%) 2.78s 2.81s p=0.014 n=6
Bind Time 1.11s (± 0.80%) 1.11s (± 0.57%) ~ 1.10s 1.12s p=1.000 n=6
Check Time 8.15s (± 0.59%) 8.18s (± 0.36%) ~ 8.15s 8.23s p=0.146 n=6
Emit Time 4.67s (± 1.09%) 4.73s (± 0.80%) ~ 4.70s 4.80s p=0.052 n=6
Total Time 16.75s (± 0.51%) 16.82s (± 0.32%) ~ 16.75s 16.90s p=0.108 n=6
TFS - node (v14.21.3, x64)
Memory used 295,139k (± 0.00%) 295,288k (± 0.00%) +149k (+ 0.05%) 295,273k 295,305k p=0.005 n=6
Parse Time 2.41s (± 0.61%) 2.40s (± 0.61%) ~ 2.39s 2.42s p=0.408 n=6
Bind Time 1.06s (± 0.38%) 1.07s (± 0.38%) +0.01s (+ 0.63%) 1.06s 1.07s p=0.034 n=6
Check Time 7.59s (± 0.34%) 7.59s (± 0.55%) ~ 7.55s 7.66s p=1.000 n=6
Emit Time 4.30s (± 0.55%) 4.34s (± 0.82%) +0.04s (+ 0.97%) 4.31s 4.41s p=0.036 n=6
Total Time 15.36s (± 0.28%) 15.40s (± 0.31%) ~ 15.33s 15.45s p=0.109 n=6
material-ui - node (v14.21.3, x64)
Memory used 476,562k (± 0.01%) 477,199k (± 0.01%) +637k (+ 0.13%) 477,164k 477,247k p=0.005 n=6
Parse Time 3.33s (± 0.45%) 3.32s (± 0.52%) ~ 3.30s 3.35s p=0.191 n=6
Bind Time 1.01s (± 0.81%) 1.00s (± 0.75%) ~ 0.99s 1.01s p=0.383 n=6
Check Time 18.74s (± 0.70%) 18.77s (± 0.63%) ~ 18.65s 18.97s p=0.630 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 23.08s (± 0.60%) 23.09s (± 0.59%) ~ 22.97s 23.34s p=1.000 n=6
xstate - node (v14.21.3, x64)
Memory used 549,594k (± 0.00%) 549,362k (± 0.00%) -232k (- 0.04%) 549,345k 549,376k p=0.005 n=6
Parse Time 4.29s (± 0.96%) 4.22s (± 0.43%) -0.07s (- 1.67%) 4.19s 4.24s p=0.005 n=6
Bind Time 1.65s (± 3.72%) 1.66s (± 2.01%) ~ 1.59s 1.68s p=0.412 n=6
Check Time 3.17s (± 0.78%) 3.17s (± 0.52%) ~ 3.16s 3.20s p=0.936 n=6
Emit Time 0.09s (± 5.53%) 0.09s (± 0.00%) ~ 0.09s 0.09s p=0.174 n=6
Total Time 9.21s (± 0.39%) 9.14s (± 0.47%) -0.07s (- 0.72%) 9.06s 9.19s p=0.012 n=6
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-148-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v18.10.0, x64)
  • node (v16.17.1, x64)
  • node (v14.21.3, x64)
Scenarios
  • Angular - node (v18.10.0, x64)
  • Angular - node (v16.17.1, x64)
  • Angular - node (v14.21.3, x64)
  • Compiler-Unions - node (v18.10.0, x64)
  • Compiler-Unions - node (v16.17.1, x64)
  • Compiler-Unions - node (v14.21.3, x64)
  • Monaco - node (v18.10.0, x64)
  • Monaco - node (v16.17.1, x64)
  • Monaco - node (v14.21.3, x64)
  • TFS - node (v18.10.0, x64)
  • TFS - node (v16.17.1, x64)
  • TFS - node (v14.21.3, x64)
  • material-ui - node (v18.10.0, x64)
  • material-ui - node (v16.17.1, x64)
  • material-ui - node (v14.21.3, x64)
  • xstate - node (v18.10.0, x64)
  • xstate - node (v16.17.1, x64)
  • xstate - node (v14.21.3, x64)
Benchmark Name Iterations
Current 54183 6
Baseline main 6

TSServer

Comparison Report - main..54183
Metric main 54183 Delta Best Worst p-value
Compiler-UnionsTSServer - node (v18.10.0, x64)
Req 1 - updateOpen 2,542ms (± 0.52%) 2,546ms (± 0.81%) ~ 2,528ms 2,583ms p=0.936 n=6
Req 2 - geterr 5,557ms (± 0.81%) 5,638ms (± 1.39%) ~ 5,491ms 5,706ms p=0.066 n=6
Req 3 - references 337ms (± 1.59%) 341ms (± 0.73%) ~ 336ms 343ms p=0.127 n=6
Req 4 - navto 290ms (± 1.21%) 284ms (± 1.00%) -5ms (- 1.84%) 283ms 290ms p=0.030 n=6
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) ~ 1,356 1,356 p=1.000 n=6
Req 5 - completionInfo 85ms (± 1.05%) 83ms (± 5.12%) ~ 74ms 85ms p=0.114 n=6
CompilerTSServer - node (v18.10.0, x64)
Req 1 - updateOpen 2,664ms (± 0.60%) 2,638ms (± 0.69%) ~ 2,602ms 2,655ms p=0.054 n=6
Req 2 - geterr 4,295ms (± 0.37%) 4,353ms (± 0.35%) +58ms (+ 1.35%) 4,337ms 4,371ms p=0.005 n=6
Req 3 - references 350ms (± 0.28%) 349ms (± 0.23%) ~ 348ms 350ms p=0.065 n=6
Req 4 - navto 292ms (± 0.64%) 290ms (± 0.18%) ~ 290ms 291ms p=0.211 n=6
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) ~ 1,518 1,518 p=1.000 n=6
Req 5 - completionInfo 64ms (± 5.55%) 62ms (± 0.66%) ~ 62ms 63ms p=0.248 n=6
xstateTSServer - node (v18.10.0, x64)
Req 1 - updateOpen 3,082ms (± 0.88%) 3,075ms (± 0.52%) ~ 3,044ms 3,090ms p=0.689 n=6
Req 2 - geterr 1,559ms (± 0.68%) 1,587ms (± 1.38%) +28ms (+ 1.81%) 1,555ms 1,622ms p=0.037 n=6
Req 3 - references 115ms (± 2.12%) 108ms (± 1.36%) 🟩-7ms (- 5.82%) 106ms 110ms p=0.005 n=6
Req 4 - navto 360ms (± 0.58%) 363ms (± 0.32%) +4ms (+ 1.02%) 362ms 365ms p=0.018 n=6
Req 5 - completionInfo count 2,862 (± 0.00%) 2,862 (± 0.00%) ~ 2,862 2,862 p=1.000 n=6
Req 5 - completionInfo 376ms (± 2.24%) 378ms (± 1.28%) ~ 372ms 385ms p=0.520 n=6
Compiler-UnionsTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 2,653ms (± 0.76%) 2,673ms (± 0.63%) ~ 2,644ms 2,692ms p=0.077 n=6
Req 2 - geterr 6,041ms (± 0.38%) 6,135ms (± 0.50%) +94ms (+ 1.55%) 6,093ms 6,180ms p=0.005 n=6
Req 3 - references 351ms (± 0.69%) 353ms (± 0.53%) ~ 350ms 355ms p=0.368 n=6
Req 4 - navto 292ms (± 1.34%) 283ms (± 0.98%) -9ms (- 2.97%) 278ms 286ms p=0.005 n=6
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) ~ 1,356 1,356 p=1.000 n=6
Req 5 - completionInfo 93ms (± 0.59%) 85ms (± 6.27%) 🟩-7ms (- 7.93%) 81ms 92ms p=0.015 n=6
CompilerTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 2,836ms (± 0.44%) 2,828ms (± 0.27%) ~ 2,818ms 2,840ms p=0.199 n=6
Req 2 - geterr 4,631ms (± 0.43%) 4,694ms (± 0.11%) +63ms (+ 1.35%) 4,688ms 4,702ms p=0.005 n=6
Req 3 - references 367ms (± 0.57%) 363ms (± 0.46%) -4ms (- 0.95%) 361ms 365ms p=0.015 n=6
Req 4 - navto 285ms (± 1.14%) 285ms (± 1.03%) ~ 282ms 289ms p=0.871 n=6
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) ~ 1,518 1,518 p=1.000 n=6
Req 5 - completionInfo 67ms (± 0.77%) 67ms (± 1.12%) ~ 66ms 68ms p=0.784 n=6
xstateTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 3,228ms (± 0.48%) 3,210ms (± 0.49%) ~ 3,192ms 3,233ms p=0.173 n=6
Req 2 - geterr 1,755ms (± 1.08%) 1,744ms (± 0.48%) ~ 1,733ms 1,752ms p=0.173 n=6
Req 3 - references 129ms (± 8.26%) 123ms (± 0.99%) ~ 121ms 124ms p=0.371 n=6
Req 4 - navto 342ms (± 0.47%) 343ms (± 0.31%) ~ 341ms 344ms p=0.508 n=6
Req 5 - completionInfo count 2,862 (± 0.00%) 2,862 (± 0.00%) ~ 2,862 2,862 p=1.000 n=6
Req 5 - completionInfo 410ms (± 1.69%) 403ms (± 0.66%) ~ 398ms 405ms p=0.124 n=6
Compiler-UnionsTSServer - node (v14.21.3, x64)
Req 1 - updateOpen 2,806ms (± 0.55%) 2,785ms (± 0.32%) -21ms (- 0.76%) 2,772ms 2,795ms p=0.020 n=6
Req 2 - geterr 6,181ms (± 0.46%) 6,346ms (± 0.55%) +164ms (+ 2.66%) 6,301ms 6,399ms p=0.005 n=6
Req 3 - references 363ms (± 0.62%) 368ms (± 1.49%) +5ms (+ 1.47%) 363ms 378ms p=0.034 n=6
Req 4 - navto 291ms (± 0.81%) 291ms (± 0.47%) ~ 289ms 293ms p=0.618 n=6
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) ~ 1,356 1,356 p=1.000 n=6
Req 5 - completionInfo 99ms (± 4.25%) 101ms (± 4.85%) ~ 92ms 105ms p=0.366 n=6
CompilerTSServer - node (v14.21.3, x64)
Req 1 - updateOpen 2,975ms (± 1.09%) 2,967ms (± 0.45%) ~ 2,945ms 2,983ms p=0.748 n=6
Req 2 - geterr 4,527ms (± 0.85%) 4,577ms (± 0.30%) +50ms (+ 1.10%) 4,557ms 4,590ms p=0.031 n=6
Req 3 - references 377ms (± 1.22%) 378ms (± 0.99%) ~ 374ms 383ms p=0.629 n=6
Req 4 - navto 299ms (± 0.30%) 297ms (± 0.65%) ~ 295ms 300ms p=0.061 n=6
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) ~ 1,518 1,518 p=1.000 n=6
Req 5 - completionInfo 76ms (± 0.83%) 76ms (± 0.54%) ~ 76ms 77ms p=0.673 n=6
xstateTSServer - node (v14.21.3, x64)
Req 1 - updateOpen 3,503ms (± 1.32%) 3,480ms (± 1.13%) ~ 3,430ms 3,534ms p=0.298 n=6
Req 2 - geterr 1,845ms (± 0.71%) 1,845ms (± 0.55%) ~ 1,831ms 1,857ms p=0.688 n=6
Req 3 - references 154ms (± 5.49%) 154ms (± 6.10%) ~ 137ms 162ms p=0.936 n=6
Req 4 - navto 395ms (± 1.13%) 395ms (± 1.68%) ~ 387ms 407ms p=0.677 n=6
Req 5 - completionInfo count 2,862 (± 0.00%) 2,862 (± 0.00%) ~ 2,862 2,862 p=1.000 n=6
Req 5 - completionInfo 430ms (± 0.89%) 432ms (± 2.20%) ~ 413ms 439ms p=0.223 n=6
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-148-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v18.10.0, x64)
  • node (v16.17.1, x64)
  • node (v14.21.3, x64)
Scenarios
  • Compiler-UnionsTSServer - node (v18.10.0, x64)
  • Compiler-UnionsTSServer - node (v16.17.1, x64)
  • Compiler-UnionsTSServer - node (v14.21.3, x64)
  • CompilerTSServer - node (v18.10.0, x64)
  • CompilerTSServer - node (v16.17.1, x64)
  • CompilerTSServer - node (v14.21.3, x64)
  • xstateTSServer - node (v18.10.0, x64)
  • xstateTSServer - node (v16.17.1, x64)
  • xstateTSServer - node (v14.21.3, x64)
Benchmark Name Iterations
Current 54183 6
Baseline main 6

Startup

Comparison Report - main..54183
Metric main 54183 Delta Best Worst p-value
tsc-startup - node (v16.17.1, x64)
Execution time 141.97ms (± 0.18%) 141.50ms (± 0.23%) -0.46ms (- 0.33%) 140.84ms 151.65ms p=0.000 n=600
tsserver-startup - node (v16.17.1, x64)
Execution time 220.97ms (± 0.22%) 220.58ms (± 0.19%) -0.39ms (- 0.18%) 219.59ms 227.99ms p=0.000 n=600
tsserverlibrary-startup - node (v16.17.1, x64)
Execution time 223.64ms (± 0.36%) 222.62ms (± 0.30%) -1.02ms (- 0.46%) 220.84ms 234.65ms p=0.000 n=600
typescript-startup - node (v16.17.1, x64)
Execution time 206.57ms (± 0.37%) 204.89ms (± 0.31%) -1.68ms (- 0.82%) 202.90ms 209.99ms p=0.000 n=600
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-148-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v16.17.1, x64)
Scenarios
  • tsc-startup - node (v16.17.1, x64)
  • tsserver-startup - node (v16.17.1, x64)
  • tsserverlibrary-startup - node (v16.17.1, x64)
  • typescript-startup - node (v16.17.1, x64)
Benchmark Name Iterations
Current 54183 6
Baseline main 6

Developer Information:

Download Benchmark

Andarist added 2 commits June 7, 2023 10:39
…inference-with-resolved-calls

# Conflicts:
#	src/compiler/checker.ts
…inference-with-resolved-calls

# Conflicts:
#	src/compiler/checker.ts
#	tests/baselines/reference/intraExpressionInferences.errors.txt
#	tests/baselines/reference/intraExpressionInferences.js
#	tests/baselines/reference/intraExpressionInferences.symbols
#	tests/baselines/reference/intraExpressionInferences.types
#	tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferences.ts
@Andarist Andarist requested a review from weswigham January 12, 2024 11:58
@Andarist Andarist force-pushed the fix/intra-expression-inference-with-resolved-calls branch from 68e3c49 to bfdaa86 Compare January 12, 2024 12:08
@weswigham
Copy link
Member

@typescript-bot perf test public

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 16, 2024

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

@weswigham
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
mui-docs - node (v20.5.1, x64)
Memory used 1,730,098k (± 0.00%) 1,730,081k (± 0.00%) ~ 1,730,041k 1,730,110k p=0.298 n=6
Parse Time 6.79s (± 0.22%) 6.80s (± 0.44%) ~ 6.75s 6.84s p=0.511 n=6
Bind Time 2.42s (± 1.75%) 2.39s (± 1.42%) ~ 2.33s 2.42s p=0.226 n=6
Check Time 52.41s (± 0.47%) 52.20s (± 0.45%) ~ 51.97s 52.53s p=0.199 n=6
Emit Time 0.15s (± 0.00%) 0.15s (± 2.69%) ~ 0.15s 0.16s p=0.405 n=6
Total Time 61.77s (± 0.46%) 61.53s (± 0.39%) ~ 61.29s 61.84s p=0.199 n=6
self-build-src - node (v20.5.1, x64)
Memory used 2,602,454k (± 2.30%) 2,717,879k (± 8.18%) ~ 2,576,888k 3,072,191k p=0.810 n=6
Parse Time 5.05s (± 1.06%) 5.06s (± 0.41%) ~ 5.04s 5.09s p=1.000 n=6
Bind Time 1.96s (± 0.42%) 1.96s (± 1.18%) ~ 1.92s 1.99s p=0.282 n=6
Check Time 32.27s (± 0.54%) 32.18s (± 0.28%) ~ 32.04s 32.27s p=0.688 n=6
Emit Time 2.76s (± 3.49%) 2.75s (± 1.33%) ~ 2.71s 2.79s p=0.688 n=6
Total Time 42.07s (± 0.54%) 41.96s (± 0.26%) ~ 41.77s 42.10s p=0.575 n=6
self-compiler - node (v20.5.1, x64)
Memory used 419,318k (± 0.01%) 419,377k (± 0.02%) ~ 419,307k 419,495k p=0.093 n=6
Parse Time 2.89s (± 0.74%) 2.88s (± 0.52%) ~ 2.87s 2.90s p=0.564 n=6
Bind Time 1.13s (± 0.46%) 1.13s (± 0.48%) ~ 1.13s 1.14s p=0.640 n=6
Check Time 14.15s (± 0.29%) 14.16s (± 0.59%) ~ 14.02s 14.24s p=0.630 n=6
Emit Time 1.03s (± 0.73%) 1.03s (± 0.87%) ~ 1.02s 1.04s p=0.798 n=6
Total Time 19.20s (± 0.20%) 19.21s (± 0.43%) ~ 19.08s 19.31s p=0.686 n=6
vscode - node (v20.5.1, x64)
Memory used 2,841,130k (± 0.00%) 2,841,091k (± 0.00%) ~ 2,841,040k 2,841,154k p=0.575 n=6
Parse Time 10.78s (± 0.14%) 10.79s (± 0.48%) ~ 10.74s 10.89s p=0.464 n=6
Bind Time 3.46s (± 0.62%) 3.44s (± 0.45%) ~ 3.43s 3.47s p=0.162 n=6
Check Time 56.59s (± 0.20%) 56.82s (± 0.51%) ~ 56.51s 57.19s p=0.173 n=6
Emit Time 16.30s (± 0.43%) 16.23s (± 0.28%) ~ 16.15s 16.26s p=0.126 n=6
Total Time 87.12s (± 0.16%) 87.28s (± 0.33%) ~ 86.95s 87.66s p=0.471 n=6
webpack - node (v20.5.1, x64)
Memory used 395,259k (± 0.01%) 395,243k (± 0.00%) ~ 395,215k 395,256k p=0.297 n=6
Parse Time 3.33s (± 0.73%) 3.32s (± 0.38%) ~ 3.30s 3.34s p=0.340 n=6
Bind Time 1.44s (± 0.76%) 1.45s (± 0.75%) ~ 1.44s 1.47s p=0.111 n=6
Check Time 12.95s (± 0.14%) 12.92s (± 0.25%) ~ 12.89s 12.97s p=0.089 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 17.73s (± 0.22%) 17.69s (± 0.20%) ~ 17.65s 17.75s p=0.172 n=6
System info unknown
Hosts
  • node (v20.5.1, x64)
Scenarios
  • mui-docs - node (v20.5.1, x64)
  • self-build-src - node (v20.5.1, x64)
  • self-compiler - node (v20.5.1, x64)
  • vscode - node (v20.5.1, x64)
  • webpack - node (v20.5.1, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@weswigham
Copy link
Member

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 16, 2024

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

Update: The results are in!

@Andarist
Copy link
Contributor Author

I'm probably not the best one to review the code specifics, but what happens if we consider all calls and new expressions to be context-sensitive?

It would definitely impact some inferences negatively. Context-sensitive functions are replaced with anyFunctionType in the first inference pass and containing objects are thus marked as non-inferrable. So I'd expect things to break with such a change even if only because the order of candidates' collection would change in certain situations. On top of that, you'd always require the second inference pass when such function expressions would be present in the arguments list - whereas right now the second pass might get skipped if all of them are annotated. So it could also affect performance in some situations.

@DanielRosenwasser
Copy link
Member

@Andarist maybe there's been a miscommunication - I was asking about all call/construct invocation expressions like

foo()
new Bar()

In #54183 (comment), it seems you're talking about all function expressions like

((x) => x))
((x: number) => x)
(<T>(x: T) => x)

@Andarist
Copy link
Contributor Author

Ah, sorry - I misread it. But isn't this what this PR is effectively doing?

    function containsContextSensitiveOrCallOrNewExpression(node: Expression | MethodDeclaration | ObjectLiteralElementLike | JsxAttributeLike | JsxChild): boolean {
        return containsContextRelatedNode(node, n => isContextSensitiveFunctionOrObjectLiteralMethod(n) || isCallOrNewExpression(n));
    }

This check doesn't have any extra checks combined with isCallOrNewExpression.

@Andarist
Copy link
Contributor Author

The reported failures here are addressed by #57909 . I believe this isn't a new issue here - it just surfaced here by the fact that more inference sites are considered. One could rewrite those call sites slightly to end up with the same broken results today.

@Andarist
Copy link
Contributor Author

#57909 was merged so the issue above is resolved now. @jakebailey could you re-run top800 and other important tests here? @DanielRosenwasser @weswigham could I ask for another review? :)

@jakebailey
Copy link
Member

@typescript-bot perf test this
@typescript-bot test top800
@typescript-bot user test this
@typescript-bot run dt

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 18, 2024

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

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

@typescript-bot
Copy link
Collaborator

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

Everything looks the same!

You can check the log here.

@typescript-bot
Copy link
Collaborator

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

Everything looks good!

@typescript-bot
Copy link
Collaborator

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

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-Unions - node (v18.15.0, x64)
Errors 30 30 ~ ~ ~ p=1.000 n=6
Symbols 62,153 62,153 ~ ~ ~ p=1.000 n=6
Types 50,242 50,242 ~ ~ ~ p=1.000 n=6
Memory used 193,235k (± 0.86%) 192,898k (± 0.76%) ~ 192,028k 195,863k p=0.575 n=6
Parse Time 1.96s (± 1.24%) 1.95s (± 0.96%) ~ 1.92s 1.97s p=0.935 n=6
Bind Time 1.06s (± 0.97%) 1.06s (± 1.19%) ~ 1.05s 1.08s p=0.560 n=6
Check Time 13.93s (± 0.32%) 13.92s (± 0.49%) ~ 13.84s 14.00s p=1.000 n=6
Emit Time 4.00s (± 0.29%) 4.08s (± 3.60%) ~ 3.99s 4.38s p=0.088 n=6
Total Time 20.95s (± 0.19%) 21.02s (± 0.99%) ~ 20.84s 21.42s p=0.468 n=6
angular-1 - node (v18.15.0, x64)
Errors 5 5 ~ ~ ~ p=1.000 n=6
Symbols 944,114 944,114 ~ ~ ~ p=1.000 n=6
Types 407,051 407,051 ~ ~ ~ p=1.000 n=6
Memory used 1,218,283k (± 0.01%) 1,218,337k (± 0.00%) ~ 1,218,280k 1,218,381k p=0.173 n=6
Parse Time 7.94s (± 0.48%) 7.94s (± 0.65%) ~ 7.86s 8.02s p=1.000 n=6
Bind Time 2.23s (± 0.72%) 2.23s (± 0.54%) ~ 2.22s 2.25s p=0.935 n=6
Check Time 35.84s (± 0.21%) 35.89s (± 0.40%) ~ 35.64s 36.02s p=0.378 n=6
Emit Time 16.18s (± 0.11%) 16.20s (± 0.33%) ~ 16.12s 16.27s p=0.518 n=6
Total Time 62.19s (± 0.13%) 62.26s (± 0.22%) ~ 62.01s 62.38s p=0.229 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,132,310 2,132,310 ~ ~ ~ p=1.000 n=6
Types 926,699 926,699 ~ ~ ~ p=1.000 n=6
Memory used 2,115,235k (± 0.01%) 2,115,194k (± 0.00%) ~ 2,115,087k 2,115,326k p=0.378 n=6
Parse Time 7.88s (± 0.76%) 7.88s (± 0.29%) ~ 7.85s 7.91s p=1.000 n=6
Bind Time 2.75s (± 0.68%) 2.76s (± 0.37%) ~ 2.75s 2.78s p=0.289 n=6
Check Time 84.22s (± 0.48%) 83.98s (± 0.35%) ~ 83.60s 84.37s p=0.336 n=6
Emit Time 0.16s (± 5.21%) 0.16s (± 3.29%) ~ 0.15s 0.16s p=0.929 n=6
Total Time 95.01s (± 0.39%) 94.78s (± 0.29%) ~ 94.44s 95.18s p=0.230 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,231,080 1,231,102 +22 (+ 0.00%) ~ ~ p=0.001 n=6
Types 261,267 261,276 +9 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 2,356,170k (± 1.02%) 2,345,851k (± 0.04%) ~ 2,345,023k 2,347,387k p=0.128 n=6
Parse Time 5.95s (± 1.10%) 5.99s (± 0.55%) ~ 5.95s 6.03s p=0.261 n=6
Bind Time 2.27s (± 0.67%) 2.27s (± 0.78%) ~ 2.24s 2.28s p=0.467 n=6
Check Time 39.84s (± 0.24%) 39.93s (± 0.19%) ~ 39.87s 40.06s p=0.128 n=6
Emit Time 3.26s (± 2.01%) 3.23s (± 3.49%) ~ 3.05s 3.37s p=0.748 n=6
Total Time 51.32s (± 0.23%) 51.43s (± 0.28%) ~ 51.31s 51.70s p=0.298 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,231,080 1,231,102 +22 (+ 0.00%) ~ ~ p=0.001 n=6
Types 261,267 261,276 +9 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 2,433,290k (± 0.98%) 2,422,033k (± 0.05%) -11,257k (- 0.46%) 2,420,886k 2,423,728k p=0.045 n=6
Parse Time 6.26s (± 0.75%) 6.24s (± 1.07%) ~ 6.14s 6.33s p=0.748 n=6
Bind Time 2.01s (± 0.73%) 2.01s (± 1.20%) ~ 1.99s 2.05s p=0.936 n=6
Check Time 40.28s (± 0.19%) 40.34s (± 0.18%) ~ 40.25s 40.43s p=0.170 n=6
Emit Time 3.09s (± 1.72%) 3.22s (± 2.05%) 🔻+0.13s (+ 4.21%) 3.14s 3.32s p=0.008 n=6
Total Time 51.66s (± 0.25%) 51.84s (± 0.14%) +0.18s (+ 0.34%) 51.75s 51.94s p=0.031 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 258,682 258,704 +22 (+ 0.01%) ~ ~ p=0.001 n=6
Types 104,901 104,910 +9 (+ 0.01%) ~ ~ p=0.001 n=6
Memory used 428,284k (± 0.01%) 428,384k (± 0.00%) +100k (+ 0.02%) 428,364k 428,398k p=0.005 n=6
Parse Time 3.32s (± 0.90%) 3.31s (± 1.00%) ~ 3.27s 3.35s p=0.809 n=6
Bind Time 1.30s (± 1.15%) 1.31s (± 0.68%) ~ 1.30s 1.32s p=0.456 n=6
Check Time 17.82s (± 0.24%) 17.79s (± 0.40%) ~ 17.73s 17.92s p=0.261 n=6
Emit Time 1.38s (± 1.65%) 1.37s (± 1.35%) ~ 1.35s 1.40s p=0.625 n=6
Total Time 23.82s (± 0.23%) 23.78s (± 0.23%) ~ 23.71s 23.86s p=0.335 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 35 35 ~ ~ ~ p=1.000 n=6
Symbols 224,565 224,565 ~ ~ ~ p=1.000 n=6
Types 93,734 93,734 ~ ~ ~ p=1.000 n=6
Memory used 369,490k (± 0.03%) 369,491k (± 0.01%) ~ 369,400k 369,526k p=0.689 n=6
Parse Time 2.77s (± 0.90%) 2.77s (± 0.80%) ~ 2.74s 2.79s p=0.934 n=6
Bind Time 1.61s (± 2.25%) 1.59s ~ ~ ~ p=0.176 n=6
Check Time 15.51s (± 0.38%) 15.52s (± 0.40%) ~ 15.44s 15.63s p=1.000 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 19.88s (± 0.32%) 19.88s (± 0.40%) ~ 19.76s 20.01s p=0.686 n=6
vscode - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,864,869 2,864,869 ~ ~ ~ p=1.000 n=6
Types 970,520 970,520 ~ ~ ~ p=1.000 n=6
Memory used 3,027,534k (± 0.00%) 3,027,500k (± 0.00%) ~ 3,027,356k 3,027,556k p=0.936 n=6
Parse Time 16.64s (± 0.24%) 16.63s (± 0.26%) ~ 16.57s 16.70s p=0.810 n=6
Bind Time 5.05s (± 0.41%) 5.04s (± 0.50%) ~ 4.99s 5.06s p=0.289 n=6
Check Time 88.73s (± 0.49%) 88.39s (± 0.59%) ~ 87.95s 89.33s p=0.230 n=6
Emit Time 29.43s (± 0.80%) 29.20s (± 0.84%) ~ 28.92s 29.60s p=0.093 n=6
Total Time 139.86s (± 0.37%) 139.25s (± 0.58%) ~ 138.50s 140.69s p=0.173 n=6
webpack - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 266,914 266,914 ~ ~ ~ p=1.000 n=6
Types 108,685 108,685 ~ ~ ~ p=1.000 n=6
Memory used 411,321k (± 0.03%) 411,251k (± 0.01%) ~ 411,216k 411,274k p=0.298 n=6
Parse Time 3.16s (± 0.35%) 3.16s (± 0.26%) ~ 3.15s 3.17s p=0.666 n=6
Bind Time 1.41s (± 0.59%) 1.41s ~ ~ ~ p=0.176 n=6
Check Time 14.27s (± 0.36%) 14.27s (± 0.33%) ~ 14.20s 14.32s p=0.936 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 18.84s (± 0.26%) 18.85s (± 0.23%) ~ 18.78s 18.90s p=1.000 n=6
xstate-main - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 523,694 523,744 +50 (+ 0.01%) ~ ~ p=0.001 n=6
Types 178,007 178,424 +417 (+ 0.23%) ~ ~ p=0.001 n=6
Memory used 461,841k (± 0.07%) 461,724k (± 0.08%) ~ 461,434k 462,216k p=0.810 n=6
Parse Time 2.63s (± 0.56%) 2.62s (± 0.51%) ~ 2.60s 2.64s p=0.560 n=6
Bind Time 0.99s (± 0.41%) 0.99s (± 0.41%) ~ 0.98s 0.99s p=0.218 n=6
Check Time 15.28s (± 0.32%) 15.21s (± 0.63%) ~ 15.10s 15.38s p=0.092 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 18.90s (± 0.23%) 18.81s (± 0.44%) ~ 18.71s 18.96s p=0.064 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

tsserver

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-UnionsTSServer - node (v18.15.0, x64)
Req 1 - updateOpen 3,180ms (±10.73%) 3,410ms (± 0.25%) ~ 3,395ms 3,419ms p=0.093 n=6
Req 2 - geterr 6,737ms (±11.21%) 7,471ms (± 0.34%) 🔻+734ms (+10.89%) 7,443ms 7,502ms p=0.031 n=6
Req 3 - references 397ms (± 0.58%) 396ms (± 0.47%) ~ 393ms 398ms p=0.516 n=6
Req 4 - navto 338ms (± 0.55%) 338ms (± 0.57%) ~ 334ms 339ms p=0.729 n=6
Req 5 - completionInfo count 1,357 1,357 ~ ~ ~ p=1.000 n=6
Req 5 - completionInfo 128ms (± 5.51%) 128ms (± 3.06%) ~ 121ms 132ms p=0.743 n=6
CompilerTSServer - node (v18.15.0, x64)
Req 1 - updateOpen 2,414ms (± 1.38%) 2,402ms (± 0.67%) ~ 2,382ms 2,423ms p=0.936 n=6
Req 2 - geterr 3,807ms (± 0.14%) 3,807ms (± 0.27%) ~ 3,792ms 3,818ms p=0.687 n=6
Req 3 - references 277ms (± 0.58%) 276ms (± 0.19%) ~ 276ms 277ms p=0.418 n=6
Req 4 - navto 227ms (± 0.18%) 227ms ~ ~ ~ p=0.405 n=6
Req 5 - completionInfo count 1,519 1,519 ~ ~ ~ p=1.000 n=6
Req 5 - completionInfo 77ms (± 8.12%) 73ms (± 2.93%) ~ 69ms 75ms p=0.459 n=6
xstate-main-1-tsserver - node (v18.15.0, x64)
Req 1 - updateOpen 5,144ms (± 0.49%) 5,144ms (± 0.44%) ~ 5,118ms 5,182ms p=1.000 n=6
Req 2 - geterr 1,134ms (± 0.99%) 1,141ms (± 1.36%) ~ 1,120ms 1,164ms p=0.470 n=6
Req 3 - references 80ms (± 4.60%) 79ms (± 5.01%) ~ 75ms 84ms p=0.740 n=6
Req 4 - navto 454ms (± 0.72%) 453ms (± 0.55%) ~ 449ms 456ms p=0.570 n=6
Req 5 - completionInfo count 3,413 3,413 ~ ~ ~ p=1.000 n=6
Req 5 - completionInfo 842ms (± 2.31%) 832ms (± 0.80%) ~ 824ms 842ms p=0.467 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • CompilerTSServer - node (v18.15.0, x64)
  • Compiler-UnionsTSServer - node (v18.15.0, x64)
  • xstate-main-1-tsserver - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

startup

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
tsc-startup - node (v18.15.0, x64)
Execution time 157.42ms (± 0.17%) 157.44ms (± 0.18%) ~ 156.43ms 160.97ms p=0.819 n=600
tsserver-startup - node (v18.15.0, x64)
Execution time 241.14ms (± 0.12%) 241.27ms (± 0.15%) +0.13ms (+ 0.06%) 239.70ms 247.87ms p=0.001 n=600
tsserverlibrary-startup - node (v18.15.0, x64)
Execution time 236.11ms (± 0.15%) 236.25ms (± 0.14%) +0.14ms (+ 0.06%) 235.00ms 243.05ms p=0.000 n=600
typescript-startup - node (v18.15.0, x64)
Execution time 236.69ms (± 0.15%) 236.69ms (± 0.16%) ~ 235.25ms 243.14ms p=0.998 n=600
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • tsc-startup - node (v18.15.0, x64)
  • tsserver-startup - node (v18.15.0, x64)
  • tsserverlibrary-startup - node (v18.15.0, x64)
  • typescript-startup - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

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

Everything looks good!

@TkDodo
Copy link

TkDodo commented May 12, 2025

@jakebailey would it be possible to get a PR preview build with the changes from here? We think there might be an issue in react-query that’s related to this and I’d like to check if this PR fixes it:

🙏

@Andarist Andarist force-pushed the fix/intra-expression-inference-with-resolved-calls branch from a9c578f to 32740a4 Compare May 12, 2025 14:25
@jakebailey
Copy link
Member

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 19, 2025

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

Command Status Results
pack this ✅ Started ✅ Results

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 19, 2025

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/165139/artifacts?artifactName=tgz&fileId=A35EB8A1813601B5F71AACABEF6E9C260578FA5D0A893F40322DE21F7C3C8F4402&fileName=/typescript-5.9.0-insiders.20250519.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.9.0-pr-54183-44".;

@TkDodo
Copy link

TkDodo commented May 19, 2025

Thank you @jakebailey ❤️ . @Andarist just confirmed that this PR fixes the issue, which is great news 🎉

@Copilot Copilot AI review requested due to automatic review settings August 4, 2025 08:21
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves TypeScript's type inference for nested generic function calls by expanding the conditions under which expressions are considered as potential intra-expression inference sites. The change addresses a bug where nested generic functions were being skipped during the first pass of type inference, leading to incomplete type resolution.

Key changes:

  • Renames isContextSensitive to containsContextSensitive for better clarity of purpose
  • Introduces containsContextSensitiveOrCallOrNewExpression to include call and new expressions as inference sites
  • Updates inference site detection to consider nested calls and constructors alongside context-sensitive functions

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/compiler/checker.ts Core logic changes to expand inference site detection and rename context sensitivity checking function
src/compiler/types.ts Updates type interface to reflect function rename
src/services/refactors/extractSymbol.ts Updates function call to use renamed containsContextSensitive
tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferencesNestedGenericCall1.ts Comprehensive test case for nested generic call inference with complex Fastify-style type provider pattern
tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferencesJsx.tsx Additional JSX test case demonstrating improved inference
tests/cases/conformance/types/typeRelationships/typeInference/intraExpressionInferences.ts Extended test cases for both object and tuple parameter patterns
Various baseline files Expected test outputs showing improved type inference results
Comments suppressed due to low confidence (2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Status: Waiting on reviewers
7 participants