-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Remove some NodePath
methods
#16655
Conversation
liuxingbaoyu
commented
Jul 17, 2024
•
edited
Loading
edited
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 |
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/57498 |
NodePath
methodsNodePath
methods
|
||
Object.assign(NodePath_Final.prototype, { | ||
// @ts-expect-error Babel 7 only | ||
has: NodePath_introspection[String("has")], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is String(...)
for?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a comment here and it seems the location is a bit far away. :)
* referencing it. | ||
*/ | ||
// eslint-disable-next-line no-restricted-globals | ||
exports.hoist = function hoist<T extends t.Node>( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
24fb6ff
to
c68e961
Compare
c68e961
to
324ddd4
Compare
324ddd4
to
439b708
Compare
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. |
@kungfooman This is to make them private and users won't be able to call them. We may avoid passing |
Yeah, in the future that will just become |