[Babel 8] Create ThisExpression for typeof this#17059
[Babel 8] Create ThisExpression for typeof this#17059nicolo-ribaudo merged 8 commits intobabel:mainfrom
typeof this#17059Conversation
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/58588 |
|
CI failure seems relevant |
Yes, sorry I forgot to update the Babel 8 fixtures. |
2b68332 to
a63ee1c
Compare
| this.next(); | ||
| entity = this.finishNode(node, "ThisExpression"); | ||
| } else { | ||
| entity = this.parseIdentifier( |
There was a problem hiding this comment.
If we don't pass ALLOW_THIS_EXPRESSION, this would still be parsed but as an identifier right? If so, I'd prefer to call it SPECIAL_THIS, THIS_AS_EXPRESSION, or (the inverse) THIS_AS_IDENTIFIER
There was a problem hiding this comment.
Yes, in this case this is still an identifier. I think this branch can only be reached by parsing typeof import("foo").this, I will see if I can rename to THIS_AS_IDENTIFIER and enable ThisExpression parsing otherwise.
nicolo-ribaudo
left a comment
There was a problem hiding this comment.
Just a naming suggestion
| "start":142,"end":146,"loc":{"start":{"line":3,"column":20,"index":142},"end":{"line":3,"column":24,"index":146},"identifierName":"this"}, | ||
| "name": "this" | ||
| "type": "ThisExpression", | ||
| "start":142,"end":146,"loc":{"start":{"line":3,"column":20,"index":142},"end":{"line":3,"column":24,"index":146}} |
There was a problem hiding this comment.
This is a Babel 8 test.
Added a new flag for
tsParseEntityName, I checked all the othertsParseEntityNameusages and it seems that onlyTSTypeQuerywould allow ThisExpression or ThisExpression within a TSQualifiedName.