-
Notifications
You must be signed in to change notification settings - Fork 12.8k
After parsing identifiers that start with two underscore another underscore is prepended #14013
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
Comments
The internal symbol tables were represented as regular objects (though we mostlly use ES6 maps now, we still support systems with no native Map implementation). The compiler adds an extra underscore, to avoid the |
@mhegazy Thanks for the information. I will use that call when retrieving the identifier name. |
@mhegazy How are developers supposed to use |
I also wish this was documented somewhere. |
The assumption is that users will not need to do that. Can you elaborate on what you are trying to do? We can expose the helper function on the |
@mhegazy I'd like the function to be exposed. I use the typescript-eslint-parser and it marks variables that start with two underscores as undefined since they are not matched to globals correctly. |
sure.. feel free to send a PR to remove the |
Thanks for following up on this @soda0289! And thanks for your support as always @mhegazy 😄 was great to have the chance to chat with you the other week. Just to be 100% clear on what @soda0289 is saying - the The behaviour he describes around actually marking variables as undefined is separate (performed within relevant ESLint rules, core or otherwise), but naturally it is all based off the ESTree AST as the source of truth, so the underlying point is valid. I will submit a PR to make |
Nice! Thanks @JamesHenry |
TypeScript Version: 2.1.5
Code
Expected behavior:
When the above typescript is parsed into an AST I would expect the Identifier of the function argument
__dirname
to start with two underscores.Actual behavior:
AST Example here:
https://astexplorer.net/#/gist/7b4386c740b3ba88a996a6f644a215c8/857121c5ac1b3cba6edb0ee8c499cb66e9919772
Identifiers prefixed with one underscore are parsed correctly, so are identifiers prefixed with three underscores.
These bugs are probably related:
#11902
#3268
The text was updated successfully, but these errors were encountered: