Repository navigation
fix(generator): do not apply jsesc number radix to non-integer literals - #18507
Merged
JLHwung merged 1 commit intoNov 3, 2026
Merged
Conversation
With `jsescOption: { numbers: "hexadecimal" | "binary" | "octal" }` the
generator handed every NumericLiteral to jsesc, which prints fractions
as `0x0.8` (for `.5`), `0b0.1` or `0o0.4`. JavaScript has no fractional
hex/binary/octal literals, so the output did not re-parse at all.
Only use the jsesc radix formatting when the value is an integer;
non-integers now fall through to the existing raw/normalized decimal
path. `numbers: "decimal"` keeps its old output for finite values.
Non-finite values now skip jsesc in every mode, because it prints an
overflowed literal such as `1e999` as `0xINFINITY` or as the `Infinity`
identifier, which can be shadowed.
Assisted-by: Claude Fable 5.1
liuxingbaoyu
approved these changes
Nov 3, 2026
|
commit: |
nicolo-ribaudo
approved these changes
Nov 3, 2026
Collaborator
|
Backported to 7.x in #18509. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
jsescOption.numbersisdecimal, Babel can generate invalid JS such as0x8.8In this PR we fixed an issue reported by Claude Fable: when
jsescOption.numbersisdecimal, Babel can generate invalid JS for non-Integer literals. There is also an upstream issue: mathiasbynens/jsesc#79. For the time being I suggest we fix it in the generator first and in the future loose the restriction here if the upstream issue is fixed.