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

Explicitly define NodePath.prototype.* #16488

Merged
merged 6 commits into from May 16, 2024

Conversation

liuxingbaoyu
Copy link
Member

@liuxingbaoyu liuxingbaoyu commented May 13, 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

babel-bot commented May 13, 2024

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

NodePath_family,
NodePath_comments,
);
Object.assign(NodePath_Final.prototype, {
Copy link
Member

Choose a reason for hiding this comment

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

Thanks! Could you declare this object outside of Object.assign, and then use it for NodePathMixins below so that they use the same data source?

const methods = {
  findParent: findParent: NodePath_ancestry.findParent,
  // ...
}
Object.assign(NodePath_Final.prototype, methods);

type NodePathMixins = Omit<typeof methods, keyof NodePathOverwrites>;

Comment on lines 258 to 265
...(!process.env.BABEL_8_BREAKING && !USE_ESM
? {
arrowFunctionToShadowed:
// workaround for rollup
// @ts-expect-error babel 7 only
NodePath_conversion[String("arrowFunctionToShadowed")],
}
: {}),
Copy link
Member

Choose a reason for hiding this comment

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

Please keep this in a separate statement, otherwise TS will include its type also in the Babel 8 build.

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.

Thanks!

After this, could you open a new PR removing in Babel 8

  • all the methods that start in _
  • all the methods that are not used outside of @babel/traverse?

@liuxingbaoyu
Copy link
Member Author

Sure! I'm a little unsure if anyone is using methods starting with _, but it probably doesn't matter.

@nicolo-ribaudo
Copy link
Member

Well _ usually means "private" -- if they need it they can open an issue and we can talk about making it part of the public API.

@nicolo-ribaudo
Copy link
Member

Could you rebase this on top of main and make sure that it still type checks properly? :)

@liuxingbaoyu
Copy link
Member Author

liuxingbaoyu commented May 15, 2024

The CI failure is from node v22.2.0.

Ref: nodejs/node#52827

Reported in nodejs/node#53011

@nicolo-ribaudo nicolo-ribaudo changed the title Explicitly define path.prototype.* Explicitly define NodePath.prototype.* May 16, 2024
@nicolo-ribaudo nicolo-ribaudo merged commit 1f010df into babel:main May 16, 2024
50 of 51 checks passed
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