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

fix(59011): TypeScript generates invalid types if @import tags are spread over multiple lines #59026

Merged
merged 6 commits into from
Jul 10, 2024

Conversation

a-tarasyuk
Copy link
Contributor

Fixes #59011

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Jun 25, 2024
@DanielRosenwasser
Copy link
Member

@typescript-bot perf test this faster

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 26, 2024

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

Command Status Results
perf test this faster ✅ Started 👀 Results

@DanielRosenwasser
Copy link
Member

@typescript-bot cherry-pick this to release-5.5

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 26, 2024

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

Command Status Results
cherry-pick this to release-5.5 ✅ Started ✅ Results

@typescript-bot
Copy link
Collaborator

Hey, @DanielRosenwasser! I've created #59039 for you.

src/compiler/parser.ts Outdated Show resolved Hide resolved
@typescript-bot
Copy link
Collaborator

@DanielRosenwasser
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 192,843k (± 0.75%) 192,665k (± 0.59%) ~ 192,116k 194,973k p=0.810 n=6
Parse Time 1.31s (± 0.94%) 1.30s (± 0.90%) ~ 1.29s 1.32s p=0.677 n=6
Bind Time 0.71s 0.71s ~ ~ ~ p=1.000 n=6
Check Time 9.42s (± 0.30%) 9.45s (± 0.34%) ~ 9.39s 9.48s p=0.143 n=6
Emit Time 2.74s (± 0.58%) 2.75s (± 0.96%) ~ 2.72s 2.79s p=0.683 n=6
Total Time 14.17s (± 0.25%) 14.21s (± 0.22%) ~ 14.16s 14.25s p=0.196 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,050 407,050 ~ ~ ~ p=1.000 n=6
Memory used 1,218,346k (± 0.00%) 1,218,369k (± 0.00%) ~ 1,218,323k 1,218,420k p=0.471 n=6
Parse Time 6.65s (± 0.78%) 6.68s (± 1.01%) ~ 6.58s 6.78s p=0.228 n=6
Bind Time 1.86s (± 0.68%) 1.86s (± 0.56%) ~ 1.84s 1.87s p=0.456 n=6
Check Time 30.61s (± 0.54%) 30.57s (± 0.31%) ~ 30.41s 30.70s p=0.748 n=6
Emit Time 13.56s (± 0.39%) 13.57s (± 0.42%) ~ 13.48s 13.65s p=0.872 n=6
Total Time 52.69s (± 0.30%) 52.68s (± 0.22%) ~ 52.51s 52.82s p=1.000 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,132,286 2,132,286 ~ ~ ~ p=1.000 n=6
Types 926,125 926,125 ~ ~ ~ p=1.000 n=6
Memory used 2,114,502k (± 0.00%) 2,114,589k (± 0.01%) ~ 2,114,441k 2,114,826k p=0.230 n=6
Parse Time 6.64s (± 0.20%) 6.67s (± 0.19%) +0.03s (+ 0.43%) 6.66s 6.69s p=0.009 n=6
Bind Time 2.33s (± 0.27%) 2.32s (± 0.90%) ~ 2.29s 2.34s p=0.615 n=6
Check Time 70.94s (± 0.47%) 70.73s (± 0.38%) ~ 70.42s 71.06s p=0.471 n=6
Emit Time 0.14s (± 6.19%) 0.14s (± 3.77%) ~ 0.13s 0.14s p=0.533 n=6
Total Time 80.05s (± 0.40%) 79.85s (± 0.35%) ~ 79.53s 80.19s p=0.575 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,231,463 1,231,478 +15 (+ 0.00%) ~ ~ p=0.001 n=6
Types 261,178 261,180 +2 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 2,347,325k (± 0.05%) 2,346,961k (± 0.03%) ~ 2,346,396k 2,347,866k p=0.575 n=6
Parse Time 5.04s (± 0.99%) 5.05s (± 0.58%) ~ 5.01s 5.09s p=0.575 n=6
Bind Time 1.92s (± 0.77%) 1.93s (± 0.84%) ~ 1.91s 1.95s p=0.144 n=6
Check Time 34.14s (± 0.28%) 34.18s (± 0.32%) ~ 34.06s 34.37s p=0.575 n=6
Emit Time 2.73s (± 3.16%) 2.81s (± 4.38%) ~ 2.65s 3.03s p=0.377 n=6
Total Time 43.85s (± 0.33%) 43.99s (± 0.27%) ~ 43.85s 44.19s p=0.128 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,231,463 1,231,478 +15 (+ 0.00%) ~ ~ p=0.001 n=6
Types 261,178 261,180 +2 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 2,424,574k (± 0.03%) 2,425,120k (± 0.02%) ~ 2,424,561k 2,425,852k p=0.093 n=6
Parse Time 7.73s (± 0.81%) 7.73s (± 1.01%) ~ 7.63s 7.85s p=0.810 n=6
Bind Time 2.53s (± 0.90%) 2.52s (± 0.54%) ~ 2.49s 2.53s p=0.286 n=6
Check Time 50.06s (± 0.27%) 50.15s (± 0.19%) ~ 50.00s 50.25s p=0.199 n=6
Emit Time 3.96s (± 1.88%) 3.88s (± 1.88%) ~ 3.81s 4.02s p=0.109 n=6
Total Time 64.28s (± 0.33%) 64.29s (± 0.26%) ~ 64.10s 64.53s p=0.936 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 258,577 258,581 +4 (+ 0.00%) ~ ~ p=0.001 n=6
Types 104,827 104,829 +2 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 428,200k (± 0.00%) 428,193k (± 0.01%) ~ 428,149k 428,231k p=0.810 n=6
Parse Time 3.31s (± 0.30%) 3.33s (± 0.86%) ~ 3.29s 3.37s p=0.303 n=6
Bind Time 1.32s (± 1.94%) 1.30s (± 0.80%) ~ 1.28s 1.31s p=0.167 n=6
Check Time 17.79s (± 0.28%) 17.78s (± 0.39%) ~ 17.70s 17.85s p=0.746 n=6
Emit Time 1.37s (± 1.27%) 1.37s (± 1.51%) ~ 1.33s 1.39s p=0.934 n=6
Total Time 23.80s (± 0.32%) 23.77s (± 0.39%) ~ 23.63s 23.86s p=0.629 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,507k (± 0.04%) 369,482k (± 0.02%) ~ 369,355k 369,577k p=0.936 n=6
Parse Time 2.77s (± 1.20%) 2.78s (± 0.87%) ~ 2.76s 2.82s p=0.683 n=6
Bind Time 1.60s (± 1.40%) 1.58s (± 0.48%) ~ 1.57s 1.59s p=0.161 n=6
Check Time 15.45s (± 0.16%) 15.49s (± 0.48%) ~ 15.37s 15.58s p=0.170 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 19.82s (± 0.24%) 19.86s (± 0.27%) ~ 19.78s 19.92s p=0.470 n=6
vscode - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,878,484 2,878,484 ~ ~ ~ p=1.000 n=6
Types 975,142 975,142 ~ ~ ~ p=1.000 n=6
Memory used 3,041,926k (± 0.00%) 3,041,943k (± 0.00%) ~ 3,041,917k 3,041,980k p=0.630 n=6
Parse Time 13.54s (± 0.15%) 13.51s (± 0.42%) ~ 13.42s 13.59s p=0.327 n=6
Bind Time 4.19s (± 0.47%) 4.19s (± 0.41%) ~ 4.17s 4.21s p=0.806 n=6
Check Time 73.51s (± 0.17%) 73.31s (± 0.43%) ~ 73.02s 73.90s p=0.066 n=6
Emit Time 23.99s (± 0.77%) 23.92s (± 0.34%) ~ 23.84s 24.02s p=0.748 n=6
Total Time 115.22s (± 0.24%) 114.93s (± 0.34%) -0.29s (- 0.25%) 114.65s 115.71s p=0.045 n=6
webpack - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 267,117 267,117 ~ ~ ~ p=1.000 n=6
Types 108,775 108,775 ~ ~ ~ p=1.000 n=6
Memory used 411,613k (± 0.02%) 411,575k (± 0.02%) ~ 411,504k 411,700k p=0.378 n=6
Parse Time 4.71s (± 0.35%) 4.73s (± 0.43%) ~ 4.70s 4.76s p=0.089 n=6
Bind Time 2.07s (± 0.95%) 2.07s (± 1.45%) ~ 2.02s 2.10s p=0.805 n=6
Check Time 20.78s (± 0.33%) 20.81s (± 0.38%) ~ 20.72s 20.93s p=0.688 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 27.56s (± 0.32%) 27.62s (± 0.30%) ~ 27.51s 27.72s p=0.378 n=6
xstate-main - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 525,251 525,251 ~ ~ ~ p=1.000 n=6
Types 178,574 178,574 ~ ~ ~ p=1.000 n=6
Memory used 462,767k (± 0.07%) 462,993k (± 0.06%) ~ 462,466k 463,311k p=0.128 n=6
Parse Time 3.17s (± 0.78%) 3.16s (± 0.52%) ~ 3.14s 3.19s p=0.514 n=6
Bind Time 1.16s (± 0.44%) 1.17s (± 0.70%) ~ 1.16s 1.18s p=0.523 n=6
Check Time 17.90s (± 0.43%) 17.91s (± 0.38%) ~ 17.83s 18.00s p=1.000 n=6
Emit Time 0.00s (±244.70%) 0.00s ~ ~ ~ p=0.405 n=6
Total Time 22.24s (± 0.35%) 22.24s (± 0.30%) ~ 22.16s 22.33s p=0.936 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Compiler-Unions - node (v18.15.0, x64)
  • angular-1 - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-build-src-public-api - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • ts-pre-modules - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate-main - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

tests/cases/conformance/jsdoc/importTag18.ts Show resolved Hide resolved
tests/baselines/reference/importTag7.types Show resolved Hide resolved
src/compiler/scanner.ts Outdated Show resolved Hide resolved
@typescript-bot typescript-bot added For Milestone Bug PRs that fix a bug with a specific milestone and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Jun 26, 2024
@DanielRosenwasser
Copy link
Member

I think we will schedule this for a follow-up patch. I want to get 5.5.3 out today.

@sandersn
Copy link
Member

I think this is good enough to merge once @a-tarasyuk has a chance to confirm that the scanner changes are infeasible (or, if they're feasible, to make the changes). Can you check whether adjusting fullStartPos after * does actually cause * appears after names?

@a-tarasyuk
Copy link
Contributor Author

Modifying fullStartPos in the scanner might lead to a * being added after the name or \n* being included in the node range.

/*HIGHLIGHTS*/<|[|{| kind: "reference" |}foo|]: string;
//  *   |>

The first issue can be fixed by adjusting fullStartPos for identifiers. However, the second case won't stop at the ; token because \n* is considered a valid leading asterisk within the node range...

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.

Given the complexity of a better fix, let's take this with the idea of improving the scanner's ability to skip * in the future.

(Based on discussion between me and @jakebailey .)

@a-tarasyuk would you mind bringing this branch up to date with main?

@sandersn sandersn merged commit e450c46 into microsoft:main Jul 10, 2024
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Milestone Bug PRs that fix a bug with a specific milestone
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

TypeScript generates invalid types if @import tags are spread over multiple lines
5 participants