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

Simplify handling of node:-prefixed modules in auto-imports #59702

Merged

Conversation

andrewbranch
Copy link
Member

Our previous behavior is described in #45080. The new behavior implemented here is simpler:

  • Preference inference: any node:-prefixed import that is not one of the built-ins only available with the prefix (e.g. node:test) indicates a preference for using the prefix. If no built-ins are referenced besides the ones only available with the prefix, no preference is set. Otherwise, the preference is to avoid the prefix. When a preference can be inferred from the imports in a single file, that will be used for auto-imports in that file. Otherwise, the same algorithm is used for all imports in non-node_modules, non-declaration files.
  • Both codefixes and completions only offer auto-imports matching the inferred preference. If no preference could be inferred, both variants are offered. (Generally, this means new projects will see both options the first time they auto-import a built-in module, and then never again.)

@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Aug 20, 2024
@andrewbranch
Copy link
Member Author

@typescript-bot perf test

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 20, 2024

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

Command Status Results
perf test ✅ Started 👀 Results

@typescript-bot
Copy link
Collaborator

@andrewbranch
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,011k (± 0.74%) 193,596k (± 0.91%) ~ 192,352k 195,900k p=0.689 n=6
Parse Time 1.57s (± 0.94%) 1.58s (± 0.78%) ~ 1.56s 1.59s p=0.408 n=6
Bind Time 0.86s (± 0.60%) 0.86s (± 1.27%) ~ 0.84s 0.87s p=0.324 n=6
Check Time 11.39s (± 0.12%) 11.41s (± 0.23%) ~ 11.38s 11.45s p=0.221 n=6
Emit Time 3.24s (± 0.54%) 3.23s (± 0.77%) ~ 3.21s 3.27s p=0.685 n=6
Total Time 17.05s (± 0.13%) 17.08s (± 0.15%) ~ 17.05s 17.12s p=0.076 n=6
angular-1 - node (v18.15.0, x64)
Errors 7 7 ~ ~ ~ p=1.000 n=6
Symbols 945,753 945,753 ~ ~ ~ p=1.000 n=6
Types 410,067 410,067 ~ ~ ~ p=1.000 n=6
Memory used 1,222,683k (± 0.00%) 1,222,703k (± 0.00%) ~ 1,222,677k 1,222,754k p=0.296 n=6
Parse Time 7.91s (± 0.65%) 7.89s (± 0.34%) ~ 7.84s 7.92s p=0.294 n=6
Bind Time 2.21s (± 0.67%) 2.21s (± 0.44%) ~ 2.20s 2.23s p=1.000 n=6
Check Time 36.31s (± 0.15%) 36.38s (± 0.40%) ~ 36.21s 36.53s p=0.689 n=6
Emit Time 17.75s (± 0.89%) 17.76s (± 0.48%) ~ 17.64s 17.88s p=1.000 n=6
Total Time 64.17s (± 0.24%) 64.23s (± 0.27%) ~ 64.06s 64.52s p=0.630 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,508,161 2,508,161 ~ ~ ~ p=1.000 n=6
Types 992,225 992,225 ~ ~ ~ p=1.000 n=6
Memory used 2,375,653k (± 0.00%) 2,375,721k (± 0.00%) ~ 2,375,603k 2,375,815k p=0.229 n=6
Parse Time 13.57s (± 0.16%) 13.62s (± 0.31%) ~ 13.57s 13.68s p=0.052 n=6
Bind Time 3.24s (± 0.61%) 3.24s (± 0.80%) ~ 3.21s 3.28s p=0.742 n=6
Check Time 107.24s (± 0.44%) 107.11s (± 0.32%) ~ 106.50s 107.49s p=0.471 n=6
Emit Time 0.39s (± 3.39%) 0.40s (± 2.74%) ~ 0.38s 0.41s p=0.306 n=6
Total Time 124.44s (± 0.38%) 124.36s (± 0.27%) ~ 123.72s 124.72s p=0.575 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,231,998 1,231,997 -1 (- 0.00%) ~ ~ p=0.001 n=6
Types 264,591 264,572 -19 (- 0.01%) ~ ~ p=0.001 n=6
Memory used 2,353,766k (± 0.02%) 2,353,934k (± 0.02%) ~ 2,353,272k 2,354,327k p=0.575 n=6
Parse Time 6.06s (± 1.10%) 6.01s (± 1.10%) ~ 5.95s 6.11s p=0.298 n=6
Bind Time 2.27s (± 0.76%) 2.25s (± 1.27%) ~ 2.21s 2.30s p=0.145 n=6
Check Time 40.97s (± 0.32%) 41.12s (± 0.20%) ~ 41.02s 41.25s p=0.093 n=6
Emit Time 4.14s (± 4.07%) 4.02s (± 1.55%) ~ 3.91s 4.08s p=0.575 n=6
Total Time 53.46s (± 0.48%) 53.42s (± 0.22%) ~ 53.26s 53.58s p=0.810 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,231,998 1,231,997 -1 (- 0.00%) ~ ~ p=0.001 n=6
Types 264,591 264,572 -19 (- 0.01%) ~ ~ p=0.001 n=6
Memory used 2,428,353k (± 0.04%) 2,428,895k (± 0.02%) ~ 2,427,853k 2,429,566k p=0.689 n=6
Parse Time 7.77s (± 0.72%) 7.72s (± 0.76%) ~ 7.64s 7.81s p=0.230 n=6
Bind Time 2.66s (± 6.53%) 2.51s (± 1.50%) ~ 2.47s 2.58s p=0.146 n=6
Check Time 51.49s (± 0.78%) 51.23s (± 0.74%) ~ 50.90s 51.78s p=0.378 n=6
Emit Time 5.03s (± 0.91%) 5.08s (± 2.92%) ~ 4.97s 5.38s p=0.630 n=6
Total Time 66.96s (± 0.43%) 66.57s (± 0.53%) ~ 66.21s 67.13s p=0.066 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 256,992 257,004 +12 (+ 0.00%) ~ ~ p=0.001 n=6
Types 105,667 105,761 +94 (+ 0.09%) ~ ~ p=0.001 n=6
Memory used 429,661k (± 0.02%) 429,705k (± 0.02%) ~ 429,605k 429,887k p=0.575 n=6
Parse Time 3.36s (± 0.53%) 3.35s (± 0.85%) ~ 3.31s 3.39s p=0.466 n=6
Bind Time 1.29s (± 0.94%) 1.29s (± 0.91%) ~ 1.28s 1.31s p=0.718 n=6
Check Time 18.07s (± 0.12%) 18.16s (± 0.39%) ~ 18.07s 18.24s p=0.054 n=6
Emit Time 1.65s (± 1.55%) 1.66s (± 1.76%) ~ 1.63s 1.71s p=0.806 n=6
Total Time 24.37s (± 0.21%) 24.46s (± 0.41%) ~ 24.30s 24.58s p=0.090 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 68 68 ~ ~ ~ p=1.000 n=6
Symbols 225,018 225,018 ~ ~ ~ p=1.000 n=6
Types 94,249 94,249 ~ ~ ~ p=1.000 n=6
Memory used 370,179k (± 0.01%) 370,216k (± 0.02%) ~ 370,124k 370,334k p=0.471 n=6
Parse Time 2.77s (± 0.72%) 2.75s (± 0.58%) ~ 2.72s 2.76s p=0.121 n=6
Bind Time 1.57s (± 0.53%) 1.57s (± 0.63%) ~ 1.56s 1.58s p=0.588 n=6
Check Time 15.74s (± 0.36%) 15.74s (± 0.28%) ~ 15.67s 15.80s p=1.000 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 20.08s (± 0.28%) 20.05s (± 0.27%) ~ 19.99s 20.14s p=0.470 n=6
vscode - node (v18.15.0, x64)
Errors 66 66 ~ ~ ~ p=1.000 n=6
Symbols 3,017,597 3,017,597 ~ ~ ~ p=1.000 n=6
Types 1,038,326 1,038,326 ~ ~ ~ p=1.000 n=6
Memory used 3,137,064k (± 0.00%) 3,137,087k (± 0.00%) ~ 3,137,029k 3,137,130k p=0.422 n=6
Parse Time 17.23s (± 0.46%) 17.28s (± 0.36%) ~ 17.21s 17.37s p=0.421 n=6
Bind Time 5.22s (± 0.16%) 5.26s (± 1.93%) ~ 5.20s 5.47s p=0.565 n=6
Check Time 97.31s (± 0.57%) 97.45s (± 0.44%) ~ 96.91s 97.95s p=1.000 n=6
Emit Time 25.00s (± 0.77%) 24.95s (± 0.42%) ~ 24.82s 25.07s p=1.000 n=6
Total Time 144.77s (± 0.41%) 144.95s (± 0.25%) ~ 144.54s 145.42s p=0.575 n=6
webpack - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 275,310 275,310 ~ ~ ~ p=1.000 n=6
Types 112,431 112,431 ~ ~ ~ p=1.000 n=6
Memory used 424,211k (± 0.02%) 424,175k (± 0.02%) ~ 424,082k 424,337k p=0.378 n=6
Parse Time 3.98s (± 0.47%) 3.98s (± 0.52%) ~ 3.94s 3.99s p=0.935 n=6
Bind Time 1.72s (± 1.44%) 1.74s (± 0.79%) ~ 1.72s 1.75s p=0.460 n=6
Check Time 17.54s (± 0.27%) 17.58s (± 0.30%) ~ 17.52s 17.67s p=0.226 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 23.24s (± 0.24%) 23.29s (± 0.28%) ~ 23.18s 23.38s p=0.092 n=6
xstate-main - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 534,554 534,554 ~ ~ ~ p=1.000 n=6
Types 176,379 176,379 ~ ~ ~ p=1.000 n=6
Memory used 479,387k (± 0.01%) 479,399k (± 0.01%) ~ 479,340k 479,468k p=0.810 n=6
Parse Time 2.84s (± 0.74%) 2.83s (± 0.52%) ~ 2.81s 2.85s p=0.368 n=6
Bind Time 1.04s (± 0.80%) 1.05s (± 0.78%) ~ 1.03s 1.05s p=0.673 n=6
Check Time 15.32s (± 0.26%) 15.30s (± 0.20%) ~ 15.25s 15.34s p=0.192 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 19.21s (± 0.24%) 19.18s (± 0.16%) ~ 19.12s 19.21s p=0.126 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 2,300ms (± 0.14%) 2,298ms (± 0.16%) ~ 2,292ms 2,302ms p=0.629 n=6
Req 2 - geterr 5,175ms (± 0.64%) 5,162ms (± 0.33%) ~ 5,139ms 5,183ms p=0.810 n=6
Req 3 - references 263ms (± 0.91%) 262ms (± 0.20%) ~ 262ms 263ms p=0.923 n=6
Req 4 - navto 227ms (± 0.54%) 227ms (± 0.71%) ~ 224ms 229ms p=0.673 n=6
Req 5 - completionInfo count 1,357 1,357 ~ ~ ~ p=1.000 n=6
Req 5 - completionInfo 85ms (± 5.04%) 82ms (± 6.46%) ~ 76ms 87ms p=0.457 n=6
CompilerTSServer - node (v18.15.0, x64)
Req 1 - updateOpen 2,410ms (± 1.08%) 2,407ms (± 1.70%) ~ 2,348ms 2,460ms p=1.000 n=6
Req 2 - geterr 3,924ms (± 0.23%) 3,911ms (± 0.25%) -14ms (- 0.35%) 3,895ms 3,922ms p=0.045 n=6
Req 3 - references 275ms (± 1.91%) 273ms (± 0.59%) ~ 270ms 274ms p=0.869 n=6
Req 4 - navto 229ms (± 2.30%) 230ms (± 2.25%) ~ 227ms 240ms p=0.865 n=6
Req 5 - completionInfo count 1,519 1,519 ~ ~ ~ p=1.000 n=6
Req 5 - completionInfo 78ms (± 9.08%) 77ms (± 8.67%) ~ 69ms 86ms p=1.000 n=6
xstate-main-1-tsserver - node (v18.15.0, x64)
Req 1 - updateOpen 5,192ms (± 0.31%) 5,192ms (± 0.18%) ~ 5,176ms 5,204ms p=0.630 n=6
Req 2 - geterr 1,134ms (± 1.86%) 1,130ms (± 1.05%) ~ 1,111ms 1,141ms p=0.575 n=6
Req 3 - references 87ms (± 4.06%) 89ms (± 4.02%) ~ 84ms 92ms p=0.511 n=6
Req 4 - navto 444ms (± 0.88%) 441ms (± 0.20%) ~ 440ms 442ms p=0.084 n=6
Req 5 - completionInfo count 3,444 3,444 ~ ~ ~ p=1.000 n=6
Req 5 - completionInfo 836ms (± 1.45%) 820ms (± 1.54%) -17ms (- 1.97%) 806ms 837ms p=0.045 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.90ms (± 0.17%) 158.10ms (± 0.17%) +0.20ms (+ 0.13%) 157.06ms 160.28ms p=0.000 n=600
tsserver-startup - node (v18.15.0, x64)
Execution time 231.95ms (± 0.13%) 231.97ms (± 0.14%) ~ 230.61ms 238.21ms p=0.835 n=600
tsserverlibrary-startup - node (v18.15.0, x64)
Execution time 227.70ms (± 0.15%) 227.50ms (± 0.14%) -0.20ms (- 0.09%) 226.00ms 231.27ms p=0.000 n=600
typescript-startup - node (v18.15.0, x64)
Execution time 227.77ms (± 0.14%) 227.82ms (± 0.23%) ~ 226.38ms 244.53ms p=0.516 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

Copy link
Member

@sheetalkamat sheetalkamat left a comment

Choose a reason for hiding this comment

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

Change looks good to me but pls fix the knip issue

@andrewbranch andrewbranch changed the title Simplify handling of node:-prefixed modules Simplify handling of node:-prefixed modules in auto-imports Aug 21, 2024
@andrewbranch andrewbranch merged commit a5eec24 into microsoft:main Aug 21, 2024
32 checks passed
@andrewbranch andrewbranch deleted the auto-imports-consistent-node-prefix branch August 21, 2024 23:43
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 5.7.0 milestone Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants