Skip to content

fix(es5): fix parseInt and parseFloat input type #50829

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

Closed
wants to merge 1 commit into from

Conversation

rafikalid
Copy link

Fix parseInt and parseFloat input type issue
issues
#50828
#17203
#38471

@typescript-bot
Copy link
Collaborator

It looks like you've sent a pull request to update our 'lib' files. These files aren't meant to be edited by hand, as they consist of last-known good states of the compiler and are generated from 'src/lib' or possibly our lib generator. Unless this is necessary, consider closing the pull request and sending a separate PR to update 'src/lib' or https://github.com/microsoft/TypeScript-DOM-lib-generator

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Sep 18, 2022
@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

@typescript-bot typescript-bot added the lib update PR modifies files in the `lib` folder label Sep 18, 2022
@fatcerberus
Copy link

This almost certainly won’t be accepted. Note #17203 is tagged working as intended (and for good reason).

@rafikalid
Copy link
Author

This almost certainly won’t be accepted. Note #17203 is tagged working as intended (and for good reason).

When I need to convert a number into an integer, I use this :
const myInteger= parseInt(542.33)
the same If I want to convert a big Integer into int.
I don't have a reason why limit this to string when to real API allows any type of data?

@XieJiSS
Copy link

XieJiSS commented Sep 18, 2022

I don't have a reason why limit this to string when to real API allows any type of data?

IMO TypeScript prevents people from doing dumb things, e.g. use parseInt to remove fraction part from a number

@MartinJohns
Copy link
Contributor

I don't have a reason why limit this to string when to real API allows any type of data?

The real API also allows to pass objects and arrays.

@RyanCavanaugh
Copy link
Member

The current behavior is intentional.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug lib update PR modifies files in the `lib` folder
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants