Skip to content

Improve using declaration errors#17333

Merged
JLHwung merged 6 commits into
babel:mainfrom
JLHwung:improve-using-declaration-errors
May 31, 2025
Merged

Improve using declaration errors#17333
JLHwung merged 6 commits into
babel:mainfrom
JLHwung:improve-using-declaration-errors

Conversation

@JLHwung
Copy link
Copy Markdown
Contributor

@JLHwung JLHwung commented May 26, 2025

Q                       A
Fixed Issues? Improve error messages on invalid production export default using x and TS declare using x.
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

@JLHwung JLHwung added PR: Polish 💅 A type of pull request used for our changelog categories Spec: Explicit Resource Management labels May 26, 2025
@babel-bot
Copy link
Copy Markdown
Collaborator

babel-bot commented May 26, 2025

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

this.match(tt._var) ||
this.isLet() ||
(this.hasPlugin("explicitResourceManagement") &&
((this.isContextual(tt._using) && this.startsUsing()) ||
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.

Nit: could we move the this.isContextual(tt._using) inside this.startsUsing() (and maybe rename it to isUsing, similar to isLet)? Just because we are checking this.isContextual(tt._using) first every time we call this.startsUsing() anyway.

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.

okay, we often call startsUsing in a big switch case so isContextual would introduce a duplicate using token check. But it probably has little impact on the performance.

@JLHwung JLHwung force-pushed the improve-using-declaration-errors branch from 1672fe9 to 6efb2d9 Compare May 29, 2025 17:45
@JLHwung JLHwung requested a review from liuxingbaoyu May 30, 2025 12:49
@JLHwung JLHwung force-pushed the improve-using-declaration-errors branch from c4af333 to 06e3516 Compare May 30, 2025 13:19

case tt._await:
// [+Await] await [no LineTerminator here] using [no LineTerminator here] BindingList[+Using]
if (!this.state.containsEsc && this.startsAwaitUsing()) {
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.

startsAwaitUsing seems to have no reference anymore, let's remove it?

@JLHwung JLHwung merged commit d3215a2 into babel:main May 31, 2025
58 checks passed
@JLHwung JLHwung deleted the improve-using-declaration-errors branch May 31, 2025 22:20
@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 Aug 31, 2025
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 31, 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 PR: Polish 💅 A type of pull request used for our changelog categories Spec: Explicit Resource Management

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants