Skip to content

[Babel 8]: wrap the TSImportType's argument within a TSLiteralType#17046

Merged
JLHwung merged 4 commits intobabel:mainfrom
JLHwung:tsimporttype-argument
Jan 9, 2025
Merged

[Babel 8]: wrap the TSImportType's argument within a TSLiteralType#17046
JLHwung merged 4 commits intobabel:mainfrom
JLHwung:tsimporttype-argument

Conversation

@JLHwung
Copy link
Copy Markdown
Contributor

@JLHwung JLHwung commented Jan 7, 2025

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

@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 7, 2025
@babel-bot
Copy link
Copy Markdown
Collaborator

babel-bot commented Jan 7, 2025

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

@JLHwung JLHwung marked this pull request as draft January 8, 2025 01:24
@JLHwung JLHwung marked this pull request as ready for review January 8, 2025 16:34
@JLHwung
Copy link
Copy Markdown
Contributor Author

JLHwung commented Jan 8, 2025

The CI error is not related to this PR as it is failing on main, too. It seems that the CI error is caused by nodejs/node#56350, I will investigate.

@JLHwung JLHwung force-pushed the tsimporttype-argument branch from 19144b2 to ff5f666 Compare January 9, 2025 12:55
Comment on lines +560 to +563
node.argument = super.parseExprAtom() as any;
} else {
if (process.env.BABEL_8_BREAKING) {
node.argument = this.tsParseLiteralTypeNode();
Copy link
Copy Markdown
Member

@nicolo-ribaudo nicolo-ribaudo Jan 9, 2025

Choose a reason for hiding this comment

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

For invalid things like import(1), would it be better to parse the argument as a tsParseLiteralTypeNode rather than an expression?

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.

That was my first thought, but then I realized that the tsParseLiteralTypeNode does not handle template literals. It seems that typescript-eslint adopted this approach, too. I will revise this PR.

@JLHwung JLHwung force-pushed the tsimporttype-argument branch from f07269f to 3c05933 Compare January 9, 2025 16:55
@JLHwung
Copy link
Copy Markdown
Contributor Author

JLHwung commented Jan 9, 2025

Amended the last commit for Babel 7 test changes.

@JLHwung JLHwung merged commit 9c4e3c4 into babel:main Jan 9, 2025
@JLHwung JLHwung deleted the tsimporttype-argument branch January 9, 2025 19:24
laine-hallot pushed a commit to laine-hallot/uwu-parser that referenced this pull request Mar 31, 2025
…abel#17046)

* breaking: wrap the TSImportType's argument within a TSLiteralType

* update AST fixtures

* polish: parse argument as a non-conditional type on invalid input
@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 11, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 11, 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