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-generator]: jsescOption.numbers does not affect NumericLiterals #10960

Closed
1 task
sanex3339 opened this issue Jan 4, 2020 · 5 comments · Fixed by #11028
Closed
1 task

[babel-generator]: jsescOption.numbers does not affect NumericLiterals #10960

sanex3339 opened this issue Jan 4, 2020 · 5 comments · Fixed by #11028
Labels
i: bug i: needs triage outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@sanex3339
Copy link

Bug Report

  • I would like to work on a fix!

Current Behavior
Currently, when I set:

{
    jsescOption: {
        numbers: 'hexadecimal'
    }
}

This option has not affects any numbers that @babel/generator is generated.

For example i need the following in the output generated code:

var foo = 0x1;

Expected behavior/code

{
    jsescOption: {
        numbers: 'hexadecimal'
    }
}

This option should affect any numbers that @babel/generator is generated

  • @babel/generator version: 7.7.7
  • Node/npm version: Node 12

Possible Solution
Looks like here: https://github.com/babel/babel/blob/master/packages/babel-generator/src/generators/types.js#L121
number value should be generated using jsesc like in StringLiteral

@babel-bot
Copy link
Collaborator

Hey @sanex3339! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."

@sidntrivedi012
Copy link
Contributor

@nicolo-ribaudo I would like to work on this. Can you please guide how to proceed? Thanks :)

@sanex3339
Copy link
Author

Set the options as descrived above.

With these options, all numbers should be generated in hexadecimal view:
0 -> 0x0

@sidntrivedi012
Copy link
Contributor

Made a Draft PR at #11028 . PTAL.

@sanex3339
Copy link
Author

Thank you!

@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 Jun 17, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: bug i: needs triage outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants