Repository navigation
Report element access after an instantiation expression - #65645
Open
magic-akari wants to merge 1 commit into
Open
magic-akari wants to merge 1 commit into
magic-akari wants to merge 1 commit into
Conversation
magic-akari
marked this pull request as ready for review
November 26, 2026 02:02
Contributor
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
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.