Skip to content

Don't scope backslash sequences as escapes in String.raw templates - #1081

Open
Akihiro Nagai (314systems) wants to merge 1 commit into
microsoft:masterfrom
314systems:fix/string-raw-escapes
Open

Akihiro Nagai (314systems) wants to merge 1 commit into
microsoft:masterfrom
314systems:fix/string-raw-escapes

Conversation

@314systems

Copy link
Copy Markdown

Fixes #1039

Adds a dedicated template-raw rule for String.raw tagged templates, so backslash sequences inside them are no longer scoped as constant.character.escape.

A backslash is still consumed together with the following character, so \` doesn't close the template and \${ doesn't start a substitution (matching runtime behavior).

Other tagged templates and plain templates are unchanged. Aliases such as const r = String.raw; r...`` can't be detected by the grammar and still get escape scopes.

Tests: added tests/cases/Issue1039.ts, all baselines pass.

🤖 Generated with Claude Code

Add a dedicated `template-raw` rule for String.raw tagged templates.
Backslashes are still consumed together with the following character,
so `\`` does not close the template and `\${` does not start a
substitution, but no constant.character.escape scope is applied.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@314systems

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Somewhat misleading escape tokens in String.raw tagged templates

2 participants