[go: nahoru, domu]

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

Added jsescOptions to Numeric Literals #11028

Merged
merged 9 commits into from
Mar 16, 2020
5 changes: 4 additions & 1 deletion packages/babel-generator/src/generators/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,11 @@ export function NullLiteral() {

export function NumericLiteral(node: Object) {
const raw = this.getPossibleRaw(node);
const opts = this.format.jsescOption;
const value = node.value + "";
if (raw == null) {
if (opts.numbers) {
this.number(jsesc(node.value, opts));
} else if (raw == null) {
this.number(value); // normalize
} else if (this.format.minified) {
this.number(raw.length < value.length ? raw : value);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let x = 42
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"jsescOption": {
"numbers": "hexadecimal",
"lowercaseHex": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let x = 0x2a;