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
Add raw
to Identifier
?
#291
Comments
Have you got some examples? |
I'm working on adding support for "Explicit Resource Management" proposal in Prettier, there are two tests added in babel PR.
They are valid, but if we format them to |
Yes, unescaping an identifier is not always safe. Here is a similar test in current ES: for (async of []); // invalid
for (\u0061sync of []); // valid However, from ESTree's perspective, I don't think we should expand the AST. Instead it should be a generator/printer rule that identifier names are not always safe to unescape. First, In another hand, if ESTree were a CST standard, we should definitely record that which characters have been escaped. |
Thanks for sharing more examples.
Yes, it's like Maybe I should ask parser to extend I just noticed that |
Yes, as a reminder, ESTree is not a spec that parsers must adhere to, but rather a loose agreement between Babel, ESLint, and Acorn around what to expect in an AST. The problem with adding new properties to existing objects is that there will never be any guarantee that those new properties will be present, so you can’t rely on that data being present either way. For this case, I think it’s better to work with specific parsers you want to use to add in additional info. |
Here's what I think it would look like if there were a shared CST format: |
In some cases, it's unsafe to unescape
Identifier
.Because of
typeAnnotation
, it's also hard to get the raw text. Maybe we can add unescaped text toIdentifier.raw
?The text was updated successfully, but these errors were encountered: