-
Notifications
You must be signed in to change notification settings - Fork 12.8k
parseInt and parseFloat should accept any and not just strings #38471
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
Duplicate of #17203. Search terms: |
Sorry, I missed that one. If the desition was made that this behavior is intended, I accept it and don't want to repeat the argument. But if you are willing to revisit this, IMHO it would be an improvement. I already made my argument above but I have one small addition: |
|
Fair point. Though I'd like to point out that But perhaps is going to be enough for me to actually start writing |
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
TypeScript Version: 3.8.3 (playground)
Search Terms:
Code
Expected behavior:
parseInt
andparseFloat
acceptsany
.The spec gives the function the signature
parseInt ( string, radix )
but also states that the argument will be converted to string internally (Let inputString be ? ToString(string).
).In my opinion, the type system should allow relaying on the behavior:
IMHO duplicate type checks should not be encouraged.
Actual behavior:
The first
parseInt
call returns the type error:Playground Link: here
The text was updated successfully, but these errors were encountered: