Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text between Unicode escapes within an identifier is skipped #61043

Open
graphemecluster opened this issue Jan 24, 2025 · 1 comment · May be fixed by #61042
Open

Text between Unicode escapes within an identifier is skipped #61043

graphemecluster opened this issue Jan 24, 2025 · 1 comment · May be fixed by #61042
Labels
Bug A bug in TypeScript Help Wanted You can do this
Milestone

Comments

@graphemecluster
Copy link
Contributor

🔎 Search Terms

  • Unicode escape sequences
  • extended Unicode escapes
  • variables, constants, property names, JSX identifiers, JSX attribute names…
  • regular expression group names, RegExp identifiers
  • bundling & transpilation

🕗 Version & Regression Information

⏯ Playground Link

https://www.typescriptlang.org/play/?#code/MYewdgzgLgBAhgHQK4G8BsAmAvsZ6AsWApjALwz4YDcAUHAEbAAmRVMA9OzAKIBOvIXgC4YAYThgwIWADMAlmCYwwcALYkA5A2ZENAOhgAROUoCeIJDHUSYWvJhz3CugPx16LNpxgA5EDCJ+QRpQSFg8AHY0LDheewBOGPoAGxJySloAN1i5BlSvLj4BYTEJKVkFJRV1W2zeXJTdA2MzCysiGw1I6NiEpNSNN0yG-I4uPwCg3hogA

💻 Code

const a\u{62}c\u{64}e = 42;
abcde; // Error: Cannot find name 'abcde'. Did you mean 'a\u{62}c\u{64}e'?
abde; // No error
const \u{76}ar\u{69}able = 42;
variable; // Error: Cannot find name 'variable'. Did you mean '\u{76}ar\u{69}able'?
viable; // No error

🙁 Actual behavior

abde and viable are recognised but not abcde and variable.

🙂 Expected behavior

abcde and variable are recognised but not abde and viable.

Additional information about the issue

Precisely, text between a 4-digit or extended Unicode escape and an extended Unicode escape is ignored.
(This is not the case for text between a 4-digit or extended Unicode escape and a 4-digit Unicode escape.)
This happens with all kinds of identifiers, not just variable names, due to the missing line result += text.substring(start, pos);. This issue is opened just for trackability and is fixed in #61042.

@graphemecluster
Copy link
Contributor Author

In TS playground, ^? expands Unicode escapes in property names but not variable names:

const foo = { \u{62}aaaa\u{72}: 42 };
//    ^? [const foo: { br: number; }]

@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript Help Wanted You can do this labels Jan 24, 2025
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants