Repository navigation
Report element access after an instantiation expression - #65645
magic-akari wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟢 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
|
TypeScript Bot (@typescript-bot) test it |
|
Hey Jake Bailey (@jakebailey), the results of running the DT tests are ready. Everything looks the same! |
|
Jake Bailey (@jakebailey) Here are the results of running the user tests with tsc comparing Everything looks good! |
|
Jake Bailey (@jakebailey) Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Jake Bailey (@jakebailey) Here are the results of running the top 400 repos with tsc comparing Everything looks good! |
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.