Skip to content

Conversation

liuxingbaoyu
Copy link
Member

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

@babel-bot
Copy link
Collaborator

babel-bot commented Mar 8, 2025

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

@liuxingbaoyu liuxingbaoyu added PR: Polish 💅 A type of pull request used for our changelog categories pkg: types labels Mar 8, 2025
@nicolo-ribaudo nicolo-ribaudo added PR: New Feature 🚀 A type of pull request used for our changelog categories and removed PR: Polish 💅 A type of pull request used for our changelog categories labels Mar 21, 2025
@@ -7,28 +7,39 @@ import type * as t from "../index.ts";
*/
export default function traverseFast<Options = object>(
node: t.Node | null | undefined,
enter: (node: t.Node, opts?: Options) => void,
enter: (node: t.Node, opts?: Options) => void | "skip" | "stop",
Copy link
Member

Choose a reason for hiding this comment

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

Wdyt about returning t.traferseFast.skip and t.traverseFast.stop symbols instead of strings? We usually don't have this type of magic strings to control behavior in our public API.

Copy link
Member Author

Choose a reason for hiding this comment

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

Strings seem to be a bit clearer in terms of type definition?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

It looks like @JLHwung prefers symbols too, so I'll use that. :)

Copy link
Member Author

Choose a reason for hiding this comment

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

It seems that TS allows us to use typeof traverseFast.skip directly.
image

Copy link
Member

Choose a reason for hiding this comment

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

Oh nice

@nicolo-ribaudo nicolo-ribaudo added this to the v7.27.0 milestone Mar 21, 2025
}
return t.traverseFast(expression, node => {
if (t.isPrivateName(node)) {
return "stop";
Copy link
Member

Choose a reason for hiding this comment

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

Is this guaranteed to use a new-enough version of babel types?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, this is using @babel/core.

nicolo-ribaudo
nicolo-ribaudo previously approved these changes Mar 24, 2025
Copy link
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.

Approving assuming that the answer to the two comments is positive.

@nicolo-ribaudo nicolo-ribaudo merged commit 582538c into babel:main Mar 24, 2025
55 checks passed
@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 Jul 4, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 4, 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: types PR: New Feature 🚀 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor traverse.hasType since might cause potential hard to debug issues in the future
4 participants