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

Use const enum in babel-parser #15793

Merged
merged 7 commits into from Jul 19, 2023

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Jul 17, 2023

Q                       A
Tests Added + Pass? Yes
License MIT

In this PR we merge a few constant sets into TS const enum in the @babel/parser. By doing so we can replace all enum usage by the actual bits, thanks to the babelPluginInlineConstNumericObjects customized plugin, and enable TS to check union types effectively. For example I added a few binding types to the bindingTypes union because previously it is resolved to a general number.

@JLHwung JLHwung added PR: Internal 🏠 A type of pull request used for our changelog categories pkg: parser labels Jul 17, 2023
@babel-bot
Copy link
Collaborator

babel-bot commented Jul 17, 2023

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

SCOPE_VAR = SCOPE_PROGRAM | SCOPE_FUNCTION | SCOPE_STATIC_BLOCK | SCOPE_TS_MODULE;
/* eslint-disable prettier/prettier */
export const enum ScopeFlag {
OTHER = 0b000000000,
Copy link
Member

Choose a reason for hiding this comment

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

Nit: can you vertically align them? It makes it easier to see the position of 1.

@nicolo-ribaudo nicolo-ribaudo merged commit 2290647 into babel:main Jul 19, 2023
56 of 57 checks passed
@nicolo-ribaudo nicolo-ribaudo deleted the use-const-enum-in-parser branch July 19, 2023 09:53
@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 19, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 19, 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 pkg: parser 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.

None yet

4 participants