Skip to content

Report element access after an instantiation expression - #65645

Open
magic-akari wants to merge 1 commit into
microsoft:mainfrom
magic-akari:fix/instantiation-computed-access
Open

magic-akari wants to merge 1 commit into
microsoft:mainfrom
magic-akari:fix/instantiation-computed-access

Conversation

@magic-akari

Copy link
Copy Markdown
Contributor

Report TS1477 when a non-optional element access follows an unparenthesized instantiation expression across a line break. This matches the existing diagnostic for dot access and leaves same-line comparisons, parenthesized access, and ?.[ unchanged.

@typescript-automation typescript-automation Bot added For Uncommitted Bug PR for untriaged, rejected, closed or missing bug For Backlog Bug PRs that fix a backlog bug and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Nov 23, 2026
@magic-akari
magic-akari marked this pull request as ready for review November 26, 2026 02:02
Copilot AI balanced review requested due to automatic review settings November 26, 2026 02:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

There are no active review issues for the parser diagnostic change.

No open issues 🎉

What changed in this PR

Fixes #65644 by extending the parser’s existing TS1477 diagnostic to non-optional element access following an unparenthesized instantiation expression across a line break.

Changes:

  • Shares the instantiation-access check between dot and element access parsing.
  • Adds regression coverage for ordinary line breaks, newlines inside comments, and allowed parenthesized and optional access.
  • Adds diagnostic, JavaScript, type, and symbol baselines to capture recovery behavior.
File Description
tsc/​testdata/​tests/​cases/​compiler/​instantiationExpressionBeforeElementAccess.ts Adds rejected and allowed element-access cases.
tsc/​testdata/​baselines/​reference/​compiler/​instantiationExpressionBeforeElementAccess.types Records inferred types after parser recovery.
tsc/​testdata/​baselines/​reference/​compiler/​instantiationExpressionBeforeElementAccess.symbols Records symbol resolution for the test cases.
tsc/​testdata/​baselines/​reference/​compiler/​instantiationExpressionBeforeElementAccess.js Captures emitted access and optional-chain boundaries.
tsc/​testdata/​baselines/​reference/​compiler/​instantiationExpressionBeforeElementAccess.errors.txt Records the three expected TS1477 diagnostics.
tsc/​internal/​parser/​parser.go Extracts the shared diagnostic check and applies it to non-optional element access.

Review effort: Balanced

@jakebailey

Copy link
Copy Markdown
Member

TypeScript Bot (@typescript-bot) test it

@typescript-automation

typescript-automation Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

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

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

@typescript-automation

Copy link
Copy Markdown
Contributor

Hey Jake Bailey (@jakebailey), the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-automation

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey) Here are the results of running the user tests with tsc comparing baseline and pr:

Everything looks good!

@typescript-automation

Copy link
Copy Markdown
Contributor

Jake Bailey (@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 - native
Errors 41 41 ~ ~ ~ p=1.000 n=20
Symbols 88,381 88,381 ~ ~ ~ p=1.000 n=20
Types 79,151 79,151 ~ ~ ~ p=1.000 n=20
Memory Used 106,301k (± 0.03%) 106,290k (± 0.02%) ~ 106,228k 106,386k p=0.452 n=20
Memory Allocs 1,045,805 (± 0.01%) 1,045,820 (± 0.01%) ~ 1,045,555 1,046,476 p=0.622 n=20
Config Time 0.000s 0.000s ~ ~ ~ p=1.000 n=20
Parse Time 0.038s (± 2.53%) 0.037s (± 2.59%) ~ 0.034s 0.040s p=0.338 n=20
Bind Time 0.012s (± 7.88%) 0.013s (± 9.02%) ~ 0.010s 0.016s p=0.152 n=20
Check Time 0.378s (± 0.66%) 0.379s (± 0.69%) ~ 0.372s 0.390s p=0.533 n=20
Emit Time 0.215s (± 1.01%) 0.217s (± 0.88%) ~ 0.210s 0.225s p=0.393 n=20
Total Time 0.650s (± 0.46%) 0.652s (± 0.54%) ~ 0.640s 0.666s p=0.365 n=20
angular-1 - native
Errors 63 63 ~ ~ ~ p=1.000 n=20
Symbols 753,805 753,805 ~ ~ ~ p=1.000 n=20
Types 546,821 546,821 ~ ~ ~ p=1.000 n=20
Memory Used 642,577k (± 0.01%) 642,651k (± 0.02%) ~ 642,264k 643,242k p=0.245 n=20
Memory Allocs 8,308,319 (± 0.03%) 8,309,590 (± 0.04%) ~ 8,304,901 8,330,598 p=0.312 n=20
Config Time 0.014s (± 1.77%) 0.013s (± 1.71%) ~ 0.013s 0.014s p=0.679 n=20
Parse Time 0.217s (± 1.71%) 0.220s (± 2.72%) ~ 0.199s 0.240s p=0.498 n=20
Bind Time 0.069s (± 9.69%) 0.069s (±10.23%) ~ 0.057s 0.114s p=0.978 n=20
Check Time 1.134s (± 0.83%) 1.139s (± 0.94%) ~ 1.108s 1.175s p=0.430 n=20
Emit Time 0.784s (± 0.79%) 0.784s (± 0.86%) ~ 0.766s 0.811s p=0.956 n=20
Total Time 2.237s (± 0.45%) 2.246s (± 0.54%) ~ 2.210s 2.280s p=0.275 n=20
arktype - native
Errors 0 0 ~ ~ ~ p=1.000 n=20
Symbols 676,875 676,875 ~ ~ ~ p=1.000 n=20
Types 937,868 937,868 ~ ~ ~ p=1.000 n=20
Memory Used 473,806k (± 0.01%) 473,722k (± 0.01%) -89k (- 0.02%) 473,517k 474,053k p=0.044 n=20
Memory Allocs 11,787,076 (± 0.01%) 11,786,191 (± 0.01%) ~ 11,783,824 11,793,159 p=0.165 n=20
Config Time 0.002s 0.002s (± 5.09%) ~ 0.002s 0.003s p=1.000 n=20
Parse Time 0.071s (± 2.92%) 0.070s (± 2.58%) ~ 0.062s 0.076s p=0.514 n=20
Bind Time 0.022s (±11.01%) 0.020s (± 6.02%) ~ 0.018s 0.029s p=0.368 n=20
Check Time 1.509s (± 0.70%) 1.500s (± 0.64%) ~ 1.470s 1.536s p=0.210 n=20
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=20
Total Time 1.646s (± 0.59%) 1.638s (± 0.58%) ~ 1.607s 1.668s p=0.388 n=20
class-transformer - native
Errors 0 0 ~ ~ ~ p=1.000 n=20
Symbols 45,379 45,379 ~ ~ ~ p=1.000 n=20
Types 7,571 7,571 ~ ~ ~ p=1.000 n=20
Memory Used 27,702k (± 0.03%) 27,700k (± 0.03%) ~ 27,662k 27,746k p=0.622 n=20
Memory Allocs 231,596 (± 0.05%) 231,522 (± 0.03%) ~ 231,300 231,901 p=0.231 n=20
Config Time 0.001s 0.001s ~ ~ ~ p=1.000 n=20
Parse Time 0.017s (± 1.99%) 0.017s (± 2.58%) ~ 0.015s 0.018s p=0.944 n=20
Bind Time 0.006s (±10.46%) 0.006s (±12.80%) ~ 0.004s 0.010s p=0.736 n=20
Check Time 0.015s (± 6.14%) 0.015s (± 6.56%) ~ 0.013s 0.018s p=0.865 n=20
Emit Time 0.016s (± 5.85%) 0.016s (± 6.85%) ~ 0.013s 0.020s p=0.972 n=20
Total Time 0.055s (± 1.34%) 0.056s (± 1.29%) ~ 0.053s 0.059s p=0.529 n=20
effect - native
Errors 4 4 ~ ~ ~ p=1.000 n=20
Symbols 1,233,598 1,233,598 ~ ~ ~ p=1.000 n=20
Types 890,152 890,152 ~ ~ ~ p=1.000 n=20
Memory Used 938,531k (± 0.02%) 938,511k (± 0.01%) ~ 938,062k 939,022k p=0.956 n=20
Memory Allocs 11,681,208 (± 0.04%) 11,682,259 (± 0.07%) ~ 11,675,451 11,755,808 p=0.245 n=20
Config Time 0.006s 0.006s ~ ~ ~ p=1.000 n=20
Parse Time 0.333s (± 1.55%) 0.329s (± 1.55%) ~ 0.310s 0.348s p=0.245 n=20
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=20
Check Time 1.797s (± 0.63%) 1.794s (± 0.48%) ~ 1.764s 1.847s p=0.841 n=20
Emit Time 0.964s (± 3.12%) 0.969s (± 2.60%) ~ 0.885s 1.078s p=0.985 n=20
Total Time 3.267s (± 0.71%) 3.270s (± 0.68%) ~ 3.186s 3.360s p=0.927 n=20
mui-docs - native
Errors 11,405 11,405 ~ ~ ~ p=1.000 n=20
Symbols 3,692,472 3,692,472 ~ ~ ~ p=1.000 n=20
Types 1,350,271 1,350,271 ~ ~ ~ p=1.000 n=20
Memory Used 1,652,281k (± 0.09%) 1,651,667k (± 0.05%) ~ 1,648,695k 1,655,489k p=0.756 n=20
Memory Allocs 24,319,989 (± 0.04%) 24,315,279 (± 0.06%) ~ 24,267,620 24,391,863 p=0.784 n=20
Config Time 0.014s (± 1.21%) 0.014s (± 3.01%) ~ 0.014s 0.018s p=0.832 n=20
Parse Time 0.553s (± 2.21%) 0.550s (± 1.30%) ~ 0.508s 0.573s p=0.596 n=20
Bind Time 0.002s (± 5.09%) 0.002s (±19.01%) ~ 0.002s 0.006s p=0.203 n=20
Check Time 5.449s (± 0.31%) 5.464s (± 0.42%) ~ 5.398s 5.616s p=0.277 n=20
Emit Time 0.596s (± 6.37%) 0.577s (± 4.69%) ~ 0.495s 0.726s p=0.467 n=20
Total Time 7.544s (± 0.77%) 7.561s (± 0.54%) ~ 7.330s 7.655s p=0.812 n=20
sentry - native
Errors 1 1 ~ ~ ~ p=1.000 n=20
Symbols 4,781,856 4,781,856 ~ ~ ~ p=1.000 n=20
Types 2,590,628 2,590,628 ~ ~ ~ p=1.000 n=20
Memory Used 2,792,245k (± 0.03%) 2,791,328k (± 0.04%) ~ 2,788,978k 2,799,710k p=0.064 n=20
Memory Allocs 73,795,465 (± 0.16%) 73,822,635 (± 0.06%) ~ 73,575,613 73,988,698 p=0.330 n=20
Config Time 0.044s (± 0.68%) 0.044s (± 0.84%) ~ 0.043s 0.046s p=0.264 n=20
Parse Time 0.998s (± 2.84%) 0.978s (± 1.83%) ~ 0.926s 1.060s p=0.546 n=20
Bind Time 0.313s (±10.39%) 0.318s (±10.97%) ~ 0.253s 0.487s p=0.841 n=20
Check Time 13.158s (± 0.36%) 13.192s (± 0.51%) ~ 12.984s 13.518s p=0.475 n=20
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=20
Total Time 14.584s (± 0.29%) 14.603s (± 0.48%) ~ 14.411s 15.036s p=0.622 n=20
social-app - native
Errors 0 0 ~ ~ ~ p=1.000 n=20
Symbols 1,839,004 1,839,004 ~ ~ ~ p=1.000 n=20
Types 1,147,065 1,147,065 ~ ~ ~ p=1.000 n=20
Memory Used 938,524k (± 0.01%) 938,497k (± 0.01%) ~ 937,902k 938,857k p=0.927 n=20
Memory Allocs 13,260,501 (± 0.10%) 13,256,993 (± 0.08%) ~ 13,202,527 13,303,375 p=0.648 n=20
Config Time 0.013s (± 1.75%) 0.013s (± 1.71%) ~ 0.013s 0.014s p=0.293 n=20
Parse Time 0.335s (± 1.41%) 0.334s (± 1.45%) ~ 0.312s 0.350s p=0.702 n=20
Bind Time 0.079s (± 7.37%) 0.081s (± 7.66%) ~ 0.068s 0.118s p=0.517 n=20
Check Time 2.870s (± 0.49%) 2.864s (± 0.48%) ~ 2.805s 2.909s p=0.798 n=20
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=20
Total Time 3.320s (± 0.34%) 3.317s (± 0.30%) ~ 3.281s 3.356s p=0.784 n=20
strada-build-src - native
Errors 0 0 ~ ~ ~ p=1.000 n=20
Symbols 1,182,507 1,182,507 ~ ~ ~ p=1.000 n=20
Types 435,504 435,504 ~ ~ ~ p=1.000 n=20
Memory Used 1,168,238k (± 0.36%) 1,166,122k (± 0.38%) ~ 1,153,341k 1,189,958k p=0.231 n=20
Memory Allocs 39,932,327 (± 0.07%) 39,893,030 (± 0.08%) ~ 39,743,109 39,983,367 p=0.076 n=20
Config Time 0.005s (±10.90%) 0.004s (± 7.19%) ~ 0.003s 0.006s p=1.000 n=20
Parse Time 0.284s (± 1.53%) 0.288s (± 1.50%) ~ 0.277s 0.311s p=0.191 n=20
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=20
Check Time 1.716s (± 0.47%) 1.717s (± 0.34%) ~ 1.691s 1.743s p=0.701 n=20
Emit Time 0.297s (± 2.08%) 0.297s (± 2.22%) ~ 0.265s 0.323s p=0.927 n=20
Total Time 20.344s (± 0.39%) 20.384s (± 0.28%) ~ 20.191s 20.602s p=0.231 n=20
strada-compiler - native
Errors 0 0 ~ ~ ~ p=1.000 n=20
Symbols 262,139 262,139 ~ ~ ~ p=1.000 n=20
Types 195,077 195,077 ~ ~ ~ p=1.000 n=20
Memory Used 221,464k (± 0.02%) 221,437k (± 0.02%) ~ 221,197k 221,677k p=0.452 n=20
Memory Allocs 1,885,405 (± 0.01%) 1,885,384 (± 0.02%) ~ 1,883,736 1,886,867 p=1.000 n=20
Config Time 0.001s 0.001s ~ ~ ~ p=1.000 n=20
Parse Time 0.103s (± 3.80%) 0.102s (± 3.59%) ~ 0.087s 0.114s p=0.595 n=20
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=20
Check Time 0.833s (± 0.62%) 0.832s (± 0.58%) ~ 0.817s 0.852s p=0.648 n=20
Emit Time 0.087s (± 3.16%) 0.089s (± 3.83%) ~ 0.080s 0.105s p=0.401 n=20
Total Time 1.070s (± 0.68%) 1.069s (± 0.58%) ~ 1.045s 1.098s p=0.452 n=20
t3code-server - native
Errors 0 0 ~ ~ ~ p=1.000 n=20
Symbols 4,345,111 4,345,111 ~ ~ ~ p=1.000 n=20
Types 3,039,273 3,039,273 ~ ~ ~ p=1.000 n=20
Memory Used 2,392,833k (± 0.02%) 2,392,586k (± 0.02%) ~ 2,390,636k 2,394,623k p=0.452 n=20
Memory Allocs 36,910,812 (± 0.06%) 36,920,539 (± 0.04%) ~ 36,871,396 37,005,935 p=0.231 n=20
Config Time 0.006s (± 1.72%) 0.006s ~ ~ ~ p=1.000 n=20
Parse Time 0.554s (± 1.82%) 0.554s (± 1.65%) ~ 0.513s 0.589s p=0.475 n=20
Bind Time 0.142s (± 4.60%) 0.148s (± 8.61%) ~ 0.131s 0.227s p=0.799 n=20
Check Time 12.196s (± 0.43%) 12.206s (± 0.41%) ~ 12.006s 12.383s p=0.898 n=20
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=20
Total Time 12.915s (± 0.44%) 12.931s (± 0.42%) ~ 12.730s 13.158s p=0.729 n=20
tanstack-router - native
Errors 3 3 ~ ~ ~ p=1.000 n=20
Symbols 567,390 567,390 ~ ~ ~ p=1.000 n=20
Types 395,720 395,720 ~ ~ ~ p=1.000 n=20
Memory Used 311,128k (± 0.02%) 311,095k (± 0.01%) ~ 310,951k 311,224k p=0.368 n=20
Memory Allocs 3,968,385 (± 0.16%) 3,966,093 (± 0.05%) ~ 3,960,518 3,979,037 p=0.784 n=20
Config Time 0.002s 0.002s ~ ~ ~ p=1.000 n=20
Parse Time 0.082s (± 3.73%) 0.079s (± 2.72%) ~ 0.072s 0.088s p=0.293 n=20
Bind Time 0.026s (±14.74%) 0.024s (± 9.45%) ~ 0.020s 0.035s p=0.352 n=20
Check Time 1.003s (± 0.72%) 1.002s (± 0.66%) ~ 0.980s 1.039s p=0.927 n=20
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=20
Total Time 1.117s (± 0.74%) 1.111s (± 0.56%) ~ 1.092s 1.142s p=0.294 n=20
ts-pre-modules - native
Errors 87 87 ~ ~ ~ p=1.000 n=20
Symbols 230,307 230,307 ~ ~ ~ p=1.000 n=20
Types 180,514 180,514 ~ ~ ~ p=1.000 n=20
Memory Used 190,457k (± 0.02%) 190,418k (± 0.02%) ~ 190,213k 190,552k p=0.143 n=20
Memory Allocs 1,284,141 (± 0.01%) 1,284,167 (± 0.01%) ~ 1,283,675 1,284,745 p=0.622 n=20
Config Time 0.000s (±143.57%) 0.000s (±143.57%) ~ 0.000s 0.001s p=1.000 n=20
Parse Time 0.075s (± 3.11%) 0.073s (± 2.74%) ~ 0.068s 0.084s p=0.332 n=20
Bind Time 0.032s (± 6.99%) 0.033s (± 7.92%) ~ 0.025s 0.040s p=0.570 n=20
Check Time 0.552s (± 0.57%) 0.551s (± 0.68%) ~ 0.539s 0.566s p=0.756 n=20
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=20
Total Time 0.671s (± 0.57%) 0.670s (± 0.37%) ~ 0.662s 0.680s p=0.679 n=20
vscode - native
Errors 0 0 ~ ~ ~ p=1.000 n=20
Symbols 9,025,474 9,025,474 ~ ~ ~ p=1.000 n=20
Types 5,224,696 5,224,696 ~ ~ ~ p=1.000 n=20
Memory Used 6,005,606k (± 0.01%) 6,004,829k (± 0.01%) ~ 6,002,007k 6,007,762k p=0.133 n=20
Memory Allocs 66,454,531 (± 0.01%) 66,454,483 (± 0.02%) ~ 66,436,694 66,580,568 p=0.312 n=20
Config Time 0.059s (± 0.26%) 0.059s (± 0.53%) ~ 0.058s 0.060s p=0.149 n=20
Parse Time 2.226s (± 1.67%) 2.242s (± 1.26%) ~ 2.142s 2.340s p=0.622 n=20
Bind Time 0.700s (± 8.64%) 0.647s (± 4.06%) ~ 0.599s 0.805s p=0.275 n=20
Check Time 18.349s (± 0.65%) 18.457s (± 0.60%) ~ 17.992s 18.979s p=0.090 n=20
Emit Time 5.369s (± 7.40%) 5.036s (± 5.67%) ~ 4.632s 6.901s p=0.133 n=20
Total Time 26.791s (± 1.38%) 26.529s (± 1.12%) ~ 25.989s 27.997s p=0.261 n=20
webpack - native
Errors 1,385 1,385 ~ ~ ~ p=1.000 n=20
Symbols 854,120 854,120 ~ ~ ~ p=1.000 n=20
Types 599,357 599,357 ~ ~ ~ p=1.000 n=20
Memory Used 741,435k (± 0.01%) 741,457k (± 0.01%) ~ 741,110k 741,785k p=0.648 n=20
Memory Allocs 6,222,377 (± 0.11%) 6,216,369 (± 0.06%) ~ 6,206,334 6,238,696 p=0.083 n=20
Config Time 0.008s (± 2.64%) 0.008s (± 2.73%) ~ 0.008s 0.009s p=0.144 n=20
Parse Time 0.335s (± 1.95%) 0.328s (± 2.88%) ~ 0.281s 0.360s p=0.522 n=20
Bind Time 0.079s (± 7.26%) 0.085s (±11.25%) ~ 0.069s 0.147s p=0.409 n=20
Check Time 3.126s (± 0.36%) 3.113s (± 0.30%) ~ 3.079s 3.151s p=0.053 n=20
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=20
Total Time 3.596s (± 0.40%) 3.583s (± 0.36%) ~ 3.548s 3.635s p=0.097 n=20
xstate-main - native
Errors 1 1 ~ ~ ~ p=1.000 n=20
Symbols 4,381,423 4,381,423 ~ ~ ~ p=1.000 n=20
Types 4,494,120 4,494,120 ~ ~ ~ p=1.000 n=20
Memory Used 2,409,000k (± 0.01%) 2,409,084k (± 0.01%) ~ 2,408,353k 2,410,146k p=0.622 n=20
Memory Allocs 48,481,299 (± 0.01%) 48,478,243 (± 0.01%) ~ 48,468,762 48,491,863 p=0.114 n=20
Config Time 0.004s 0.004s (± 2.58%) ~ 0.004s 0.005s p=1.000 n=20
Parse Time 0.218s (± 1.49%) 0.213s (± 1.72%) ~ 0.200s 0.228s p=0.105 n=20
Bind Time 0.060s (± 3.27%) 0.067s (± 8.11%) 🔻+0.004s (+ 5.86%) 0.058s 0.103s p=0.004 n=20
Check Time 8.358s (± 0.28%) 8.335s (± 0.33%) ~ 8.166s 8.400s p=0.349 n=20
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=20
Total Time 8.648s (± 0.26%) 8.628s (± 0.28%) ~ 8.486s 8.688s p=0.430 n=20
System info unknown
Hosts
  • native
Scenarios
  • Compiler-Unions - native
  • angular-1 - native
  • arktype - native
  • class-transformer - native
  • effect - native
  • mui-docs - native
  • sentry - native
  • social-app - native
  • strada-build-src - native
  • strada-compiler - native
  • t3code-server - native
  • tanstack-router - native
  • ts-pre-modules - native
  • vscode - native
  • webpack - native
  • xstate-main - native
Benchmark Name Iterations
Current pr 20
Baseline baseline 20

Developer Information:

Download Benchmarks

@typescript-automation

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey) Here are the results of running the top 400 repos with tsc comparing baseline and pr:

Everything looks good!

This branch has not been deployed

No deployments
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

None yet

Development

Successfully merging this pull request may close these issues.

Missing diagnostic for element access after an instantiation expression across a line break

3 participants