Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove some NodePath methods #16655

Merged
merged 2 commits into from
Aug 23, 2024

Conversation

liuxingbaoyu
Copy link
Member

@liuxingbaoyu liuxingbaoyu commented Jul 17, 2024

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

@babel-bot
Copy link
Collaborator

babel-bot commented Jul 17, 2024

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

@liuxingbaoyu liuxingbaoyu changed the title Removed some NodePath methods Remove some NodePath methods Jul 17, 2024

Object.assign(NodePath_Final.prototype, {
// @ts-expect-error Babel 7 only
has: NodePath_introspection[String("has")],
Copy link
Member

Choose a reason for hiding this comment

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

What is String(...) for?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is for rollup, otherwise it will show that the export cannot be found.

Copy link
Member

Choose a reason for hiding this comment

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

Can you add a comment? :)

Copy link
Member Author

@liuxingbaoyu liuxingbaoyu Jul 17, 2024

Choose a reason for hiding this comment

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

* referencing it.
*/
// eslint-disable-next-line no-restricted-globals
exports.hoist = function hoist<T extends t.Node>(
Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity, what was this ever used for?

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 to be used by babel-plugin-transform-react-constant-elements, I'm not sure, it has no use now.

@nicolo-ribaudo nicolo-ribaudo added PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release PR: Needs Docs babel 8 labels Jul 17, 2024
Copy link
Contributor

@JLHwung JLHwung left a comment

Choose a reason for hiding this comment

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

I think we should provide specific migration docs for the NodePath introspection methods, as they can be replaced by queries on path.node. Removing them incurs more impact than the other methods.

@liuxingbaoyu liuxingbaoyu force-pushed the remove-traverse-methods branch from 324ddd4 to 439b708 Compare July 28, 2024 08:09
@kungfooman
Copy link

There is no reasoning here why the change is needed, can someone enlighten the rest of us? To me this just starts looking more complicated and unidiomatic code now, for example:

- path.resync();
+ resync.call(path);

It looks like functional programming is trying to take over and making it unreadable.

@liuxingbaoyu
Copy link
Member Author

@kungfooman This is to make them private and users won't be able to call them. We may avoid passing this in the future.

@nicolo-ribaudo
Copy link
Member

Yeah, in the future that will just become resync(path).

@nicolo-ribaudo nicolo-ribaudo requested a review from JLHwung August 22, 2024 08:44
@nicolo-ribaudo nicolo-ribaudo added this to the v8.0.0-beta milestone Aug 22, 2024
@nicolo-ribaudo nicolo-ribaudo merged commit 46ee612 into babel:main Aug 23, 2024
52 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 Nov 23, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
babel 8 outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: traverse 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.

Cleanup NodePath methods
5 participants