Repository navigation
Fix escaped keyword ASI after class field initializers (#64883) - #65014
Open
Timur Vural (timurzvural) wants to merge 1 commit into
Open
Timur Vural (timurzvural) wants to merge 1 commit into
Timur Vural (timurzvural) wants to merge 1 commit into
Conversation
Do not treat Unicode-escaped keywords as binary operators so
`\u{69}n` / `\u{69}nstanceof` after a class field initializer become
IdentifierNames (matching ECMA-262 and V8). Unescaped `in` still
continues the initializer.
AI assistance disclosure: this change was authored with Cursor Agent.
1 of 2 tasks
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the parser change allowing escaped keywords to begin new class members after field initializers.
No open issues 🎉
What changed in this PR
Fixes #64883 in the native TypeScript parser by allowing escaped keyword names after class field initializers to start new members through automatic semicolon insertion.
Changes:
- Excludes Unicode-escaped keywords from binary-operator parsing and detection.
- Adds parser tests for escaped
in/instanceoffields and preserves unescapedinas an operator.
| File | Description |
|---|---|
tsc/internal/parser/parser.go |
Adds an escaped-keyword check to both binary-operator paths. |
tsc/internal/parser/parser_test.go |
Tests escaped class field names and unescaped operator behavior. |
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.
Summary
Fixes #64883 — Escaped
in/instanceofafter class field initializers.After a class field initializer, Unicode-escaped
\u{69}n/\u{69}nstanceofon the next line were parsed as thein/instanceofoperators (TS1260 + parse error). Per ECMA-262, keyword terminals cannot be expressed with Unicode escapes, so these should be IdentifierNames (matching V8).Change: Treat escaped keywords as non-operators in the binary-operator path (
parseBinaryExpressionRest/isBinaryOperator) so ASI can end the previous expression and the escaped name can start a new class member. Unescapedinafter a field initializer still continues the expression (test262fields-asi-5.js).Test plan
TestParseEscapedInInstanceofAfterClassField,TestParseUnescapedInContinuesClassFieldInitializerRelates to
This focused PR replaces the parser portion of the combined #65013 (which is being closed in favor of two single-issue PRs).
AI assistance disclosure
This change was authored with Cursor Agent (an LLM-based coding agent). A human operator directed the investigation at this specific open issue, reviewed the resulting patch, and is submitting it for review. Per CONTRIBUTING.md, AI tool use is disclosed here.