Repository navigation
fix(parser): preserve escaped class field names across newlines - #65377
Open
Jemmy (JemmyIndex) wants to merge 1 commit into
Open
Jemmy (JemmyIndex) wants to merge 1 commit into
Jemmy (JemmyIndex) wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the parser change preserving Unicode-escaped class field names.
No open issues 🎉
What changed in this PR
Fixes #65306 in the native TypeScript parser by preserving Unicode-escaped get, set, and static as class field names when followed by a line break, avoiding incorrect diagnostics and emitted member placement.
Changes:
- Captures Unicode escape flags before advancing modifier lookahead.
- Adds regression coverage for ordinary and extended escapes, while checking existing modifier and method-name behavior.
- Adds ES2015 and ESNext diagnostic, emit, symbol, and type baselines.
| File | Description |
|---|---|
tsc/testdata/tests/cases/compiler/escapedClassFieldModifiers.ts |
Adds regression cases for escaped fields and related modifier behavior. |
tsc/testdata/baselines/reference/compiler/escapedClassFieldModifiers(target=esnext).types |
Records expected ESNext member types. |
tsc/testdata/baselines/reference/compiler/escapedClassFieldModifiers(target=esnext).symbols |
Records expected ESNext symbol bindings. |
tsc/testdata/baselines/reference/compiler/escapedClassFieldModifiers(target=esnext).js |
Verifies native class-field emit and member placement. |
tsc/testdata/baselines/reference/compiler/escapedClassFieldModifiers(target=esnext).errors.txt |
Limits expected errors to invalid same-line escaped modifiers. |
tsc/testdata/baselines/reference/compiler/escapedClassFieldModifiers(target=es2015).types |
Records expected ES2015 member types. |
tsc/testdata/baselines/reference/compiler/escapedClassFieldModifiers(target=es2015).symbols |
Records expected ES2015 symbol bindings. |
tsc/testdata/baselines/reference/compiler/escapedClassFieldModifiers(target=es2015).js |
Verifies downlevel field initialization and instance methods. |
tsc/testdata/baselines/reference/compiler/escapedClassFieldModifiers(target=es2015).errors.txt |
Preserves same-line escaped-modifier diagnostics for ES2015. |
tsc/internal/parser/parser.go |
Rejects modifier interpretation for escaped names followed by a line break. |
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.
Fixes #65306.
Unicode-escaped class field names that decode to
get,set, orstaticare currently consumed as modifiers when the next member starts on a new line. This produces TS1260 and other diagnostics for valid fields, and can change emitted instance methods into accessors or static methods.Save the current token's Unicode escape flags before advancing in
nextTokenCanFollowModifier. If the token is escaped and the following token has a preceding line break, reject the modifier interpretation so the parser rewinds and parses a field name. Ordinary multiline modifiers and diagnostics for invalid same-line escaped modifiers keep their existing behavior.Add a compiler regression case for all three names with ordinary and extended Unicode escapes, with ES2015 and ESNext emit baselines. The case also checks member access, ordinary multiline modifiers, escaped method names, and invalid same-line escaped modifiers.
Validation:
validate --allcompleted: compiler/parser/scanner/fourslash/CLI, extension, native/WASM API, tools/options, smoke, lint, and formatting checks passed apart from two Windows symlink tests. The overall command exits unsuccessfully becauseTestSubscribeSymlinkCreate/windowsandTestSubscribeSymlinkDelete/windowscannot create symlinks on this machine (A required privilege is not held by the client); their parent failures account for the other two failure records.hereby tidyandhereby check:formatpassed, with no dependency or unrelated generated-file changes.AI assistance: Codex authored the patch and regression test and ran validation for this specifically selected issue.