-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix(compress): toFixed
, toPrecision
, toExponential
and toString
of Number
#6960
Conversation
The assert.sameValue((10).toPrecision(1), "1e+1");
assert.sameValue((11).toPrecision(1), "1e+1");
assert.sameValue((17).toPrecision(1), "2e+1");
assert.sameValue((19).toPrecision(1), "2e+1");
assert.sameValue((20).toPrecision(1), "2e+1"); compress result: assert.sameValue("10", "1e+1");
assert.sameValue("11", "1e+1");
assert.sameValue("17", "2e+1");
assert.sameValue("19", "2e+1");
assert.sameValue("20", "2e+1"); |
Do you mean it's not possible at all? |
No, we can calculate the result step by step according to the ECMA262 specification. |
There are two test case files from test262. |
I think it's fine |
num.toFixed()
and num.toPrecision()
toFixed
, toPrecision
, toExponential
and toString
of Number
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
swc-bump:
- swc_ecma_minifier
crates/swc_ecma_minifier/tests/fixture/issues/6957/number-tostring/output.js
Outdated
Show resolved
Hide resolved
crates/swc_ecma_minifier/tests/fixture/issues/6957/number-tostring/output.js
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
swc-bump:
- swc_ecma_transforms_base
Description:
The code snippet from StackOverflow is for handling
toPrecision
instead oftoFixed
BREAKING CHANGE:
Related issue (if exists):