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

[babel 8] Remove methods starting with _ in @babel/traverse #16504

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

liuxingbaoyu
Copy link
Member

@liuxingbaoyu liuxingbaoyu commented May 17, 2024

Q                       A
Fixed Issues? Ref: #16443
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

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

@@ -249,13 +247,11 @@ const methods = {
_guessExecutionStatusRelativeTo:
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 has a reference externally.

this._resyncParent();
this._resyncList();
this._resyncKey();
_resyncParent.call(this);
Copy link
Member

Choose a reason for hiding this comment

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

What do you think of changing all these "private methods" to accept the NodePath as the first parameter instead of this, so that we can do _resyncParent(this) instead of _resyncParent.call(this)?

Then, in index.ts we have to do

Object.assign(NodePath_Final.prototype, {
  ...
  _resyncParent: thisify(NodePath_context._resyncParent)
  ...

where thisify is

function thisify(fn) {
  return function() {
    return fn(this, ...arguments);
  }
}

in practice those thisified functions will never be called anyway, since they are only called internally by @babel/traverse.

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe we can do this after Babel 8 is more stable and avoid us needing to expose certain methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants