microsoft / TypeScript-TmLanguage

TextMate grammar files for TypeScript for VS Code, Sublime Text, and Atom.
MIT License
415 stars 130 forks source link

Somewhat misleading escape tokens in String.raw tagged templates #1039

Open Vap0r1ze opened 4 months ago

Vap0r1ze commented 4 months ago

JavaScript and TypeScript Nightly version:

Code

// Please include a code snippet that demonstrates the issue
String.raw`--some-flag=C:\Some\Windows\Path` // It looks like the first letter of each dir is being escaped
String.raw`"This is\nJSON text\u2757"` // It looks like '\n' is being escaped
Example of how it looks in VSCode

image

Since String.raw is an EcmaScript standard, it's probably ideal that the grammar shows those string tokens without any escape tokens.

Important to note that backslashes shouldn't be ignored in the pattern, for example:

//        ╭─ Template string opener
//        ┴
String.raw`\`;
//         ─┬─
//          ╰─ Unclosed template string content