-
Notifications
You must be signed in to change notification settings - Fork 12.8k
ParseInt and ParseFloat should accept numbers and BigInt as Input #50828
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
Comments
Quote @RyanCavanaugh:
|
fix: #50829 |
When I need to convert a number into an integer, I use this : |
That's what
You could say this about most built-ins because automatic type coercion runs rampant in JS (i.e. half of the reason TS even exists). See https://stackoverflow.com/questions/41750390/what-does-all-legal-javascript-is-legal-typescript-mean |
Besides what fatcerberus said, you should really not be using the types |
Passing non-strings through |
Indeed. The key isn't that it accepts some type of data, but that it's well-behaved when passed that type. |
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Bug Report
parseInt
andparseFloat
only accept string. therefore it should acceptnumber
,Number
andbigInt
too🔎 Search Terms
🕗 Version & Regression Information
all versions
Please keep and fill in the line that best applies:
-->
⏯ Playground Link
Workbench Repro
💻 Code
Workbench Repro
🙁 Actual behavior
Those functions accept only string to parse
🙂 Expected behavior
Should accept
number
,Number
andbigInt
tooSolution
I send a PR for this. please review and merge ❤️
The text was updated successfully, but these errors were encountered: