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
Use isIdentifierChar instead of regex for toIdentifier #12575
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/36641/ |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit bdc6b36:
|
Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a test with a name whose first character is a valid identifier char, but not a valid identifier start?
@nicolo-ribaudo I've added |
I was thinking more about something non in the ASCII range, like expect(t.toIdentifier("\u0487a")).toBe(...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Non ASCII-chars that are still valid in an identifier were previously removed (so valid identifiers were turned into
_
). UseisIdentifierChar
instead as suggested in #12574 (comment)