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

Refactor visitors merging #15702

Merged
merged 2 commits into from Jul 5, 2023
Merged

Conversation

nullableVoidPtr
Copy link
Contributor

@nullableVoidPtr nullableVoidPtr commented Jun 14, 2023

Q                       A
Fixed Issues? Fixes #15587
Patch: Bug Fix? Yes
Major: Breaking Change? No(?)
Minor: New Feature? Yes
Tests Added + Pass? Yes (thanks @liuxingbaoyu!)
Documentation PR Link
Any Dependency Changes?
License MIT

I've tried to better type-polish merge, not realizing there was already an open bug and attached PR; hence, there is the relevant test added, courtesy of @liuxingbaoyu on #15593.

  • Top-level "catch-all" visitors are also wrapped then merged
  • Instead of blindly merging all keys, they are constrained to just the relevant VisitPhase
    • Allows the removal of some complex union type errors
  • If allowed to have breaking behavior, actually returns an ExplodedVisitor with internal flags attached
    • There is a failing test regarding babel/register when using babel/core < 7.13.0

@babel-bot
Copy link
Collaborator

babel-bot commented Jun 14, 2023

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

@nicolo-ribaudo nicolo-ribaudo added the PR: Internal 🏠 A type of pull request used for our changelog categories label Jun 19, 2023
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.

Thanks!

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.

Thank you! Just one question.

// @ts-expect-error Fixme: document state.key
newFn = wrapper(state.key, key, newFn);
// @ts-expect-error Fixme: actually PluginPass.key (aka pluginAlias)?
newFn = wrapper(state?.key, phase, newFn);
Copy link
Member

Choose a reason for hiding this comment

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

Can state be nullish? Or should this be state!.key? If it can be null, can you specify it in the state type signature?

nullableVoidPtr and others added 2 commits July 5, 2023 11:37
Co-authored-by: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com>
@nicolo-ribaudo nicolo-ribaudo changed the title Refactor traverse visitor merging Refactor visitors merging Jul 5, 2023
@nicolo-ribaudo nicolo-ribaudo merged commit b1de75f into babel:main Jul 5, 2023
55 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 Oct 5, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Internal 🏠 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: @babel/traverse enter/exit visitors get incorrectly merged
4 participants