Skip to content

Support supplementary CPs in Unicode identifiers #2522

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

Merged
merged 17 commits into from
Sep 26, 2022
Merged

Support supplementary CPs in Unicode identifiers #2522

merged 17 commits into from
Sep 26, 2022

Conversation

dcodeIO
Copy link
Member

@dcodeIO dcodeIO commented Sep 25, 2022

Showed up in #2495, where 4-byte Unicode characters are not accepted as identifier starts/parts by the tokenizer. In TS, there exist maps for ES3, ES5 and ESNext, and I assume our current one matches the ES5 one. This PR adds a script we can use to generate the tables for ESNext (respectively: current Unicode tables used by Node), which should be the only relevant maps for us.

On our end, the respective maps are here. For ESNext, we'll need to go from u16 to u32 since these values are codepoints.

  • I've read the contributing guidelines
  • I've added my name and email to the NOTICE file

@dcodeIO dcodeIO requested a review from MaxGraey September 25, 2022 22:43
Copy link
Member

@MaxGraey MaxGraey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Comment on lines +37 to +38
console.log(`const unicodeIdentifierStartMin = ${starts[0]};`);
console.log(`const unicodeIdentifierStartMax = ${starts[starts.length - 1]};\n`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log(`const unicodeIdentifierStartMin = ${starts[0]};`);
console.log(`const unicodeIdentifierStartMax = ${starts[starts.length - 1]};\n`);
console.log(`const UnicodeIdentifierStartMin = ${starts[0]};`);
console.log(`const UnicodeIdentifierStartMax = ${starts[starts.length - 1]};\n`);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using title case for SomeEnum.SomeValue seems fine, but just SomeValue conflicts visually with classes, enums and interfaces. Not sure it's preferable?

@dcodeIO dcodeIO changed the title Add script to generate unicode identifier starts/parts Support supplementary CPs in Unicode identifiers Sep 26, 2022
@dcodeIO dcodeIO merged commit f8a775f into main Sep 26, 2022
@HerrCai0907 HerrCai0907 deleted the unicode-ids branch October 17, 2023 08:59
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.

2 participants