Skip to content

Remove some NodePath methods#16655

Merged
nicolo-ribaudo merged 2 commits into
babel:mainfrom
liuxingbaoyu:remove-traverse-methods
Aug 23, 2024
Merged

Remove some NodePath methods#16655
nicolo-ribaudo merged 2 commits into
babel:mainfrom
liuxingbaoyu:remove-traverse-methods

Conversation

@liuxingbaoyu

@liuxingbaoyu liuxingbaoyu commented Jul 17, 2024

Copy link
Copy Markdown
Member
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

babel-bot commented Jul 17, 2024

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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? :)

@liuxingbaoyu liuxingbaoyu Jul 17, 2024

Copy link
Copy Markdown
Member Author

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
Copy Markdown
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
Copy Markdown
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

@JLHwung JLHwung left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
@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