Open purple-force opened 2 months ago
is:issue Number toFixed
No response
// Your code here
https://github.com/microsoft/TypeScript/blob/52395892e0c4ee8a22b4fa6190bad46d81e66651/src/lib/es5.d.ts#L550 https://github.com/microsoft/TypeScript/blob/52395892e0c4ee8a22b4fa6190bad46d81e66651/src/lib/es5.d.ts#L556 https://github.com/microsoft/TypeScript/blob/52395892e0c4ee8a22b4fa6190bad46d81e66651/src/lib/es5.d.ts#L562
The right range is 0 to 100 for toFixed and toExponential, 1 to 100 for toPrecision.
Spec links:
For each case, the valid range is given in step 5.
It looks like this was changed here and first appeared in ES2018 (but I don't know if the comment can be versioned or if you'd want it to be).
Since this definition is used by later version es spec and many developers don't know the history, maybe following the spec is a better choice?
🔎 Search Terms
is:issue Number toFixed
🕗 Version & Regression Information
⏯ Playground Link
No response
💻 Code
🙁 Actual behavior
https://github.com/microsoft/TypeScript/blob/52395892e0c4ee8a22b4fa6190bad46d81e66651/src/lib/es5.d.ts#L550 https://github.com/microsoft/TypeScript/blob/52395892e0c4ee8a22b4fa6190bad46d81e66651/src/lib/es5.d.ts#L556 https://github.com/microsoft/TypeScript/blob/52395892e0c4ee8a22b4fa6190bad46d81e66651/src/lib/es5.d.ts#L562
🙂 Expected behavior
The right range is 0 to 100 for toFixed and toExponential, 1 to 100 for toPrecision.
Additional information about the issue
No response