Skip to content

[Babel 8] Create ThisExpression for typeof this#17059

Merged
nicolo-ribaudo merged 8 commits intobabel:mainfrom
JLHwung:tstypequery-exprName
Jan 17, 2025
Merged

[Babel 8] Create ThisExpression for typeof this#17059
nicolo-ribaudo merged 8 commits intobabel:mainfrom
JLHwung:tstypequery-exprName

Conversation

@JLHwung
Copy link
Copy Markdown
Contributor

@JLHwung JLHwung commented Jan 10, 2025

Q                       A
Fixed Issues? #16679
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link babel/website#3041
Any Dependency Changes?
License MIT

Added a new flag for tsParseEntityName, I checked all the other tsParseEntityName usages and it seems that only TSTypeQuery would allow ThisExpression or ThisExpression within a TSQualifiedName.

@JLHwung JLHwung added PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release pkg: parser PR: Needs Docs labels Jan 10, 2025
@babel-bot
Copy link
Copy Markdown
Collaborator

babel-bot commented Jan 10, 2025

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/58588

@nicolo-ribaudo
Copy link
Copy Markdown
Member

CI failure seems relevant

@JLHwung
Copy link
Copy Markdown
Contributor Author

JLHwung commented Jan 13, 2025

CI failure seems relevant

Yes, sorry I forgot to update the Babel 8 fixtures.

this.next();
entity = this.finishNode(node, "ThisExpression");
} else {
entity = this.parseIdentifier(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

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

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}}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is a Babel 8 test.

@nicolo-ribaudo nicolo-ribaudo merged commit bdf9a9c into babel:main Jan 17, 2025
@nicolo-ribaudo nicolo-ribaudo deleted the tstypequery-exprName branch January 17, 2025 14:52
laine-hallot pushed a commit to laine-hallot/uwu-parser that referenced this pull request Mar 31, 2025
@github-actions github-actions Bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Apr 19, 2025
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: parser PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants