Skip to content

ParseInt and ParseFloat should accept numbers and BigInt as Input #50828

Closed
@rafikalid

Description

@rafikalid

Bug Report

parseInt and parseFloat only accept string. therefore it should accept number, Number and bigInt too

🔎 Search Terms

  • parseInt
  • parseFloat

🕗 Version & Regression Information

all versions

Please keep and fill in the line that best applies:
-->

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about parseInt and parseFloat

⏯ Playground Link

Workbench Repro

💻 Code

parseInt(854n); // Should work with bigInt
parseInt(548.25); // Should work too with numbers

parseFloat(854n); // Should work with bigInt
parseFloat(548.25); // Should work too with numbers

// Using wrappers
const n = new Number(55);
parseInt(n); // Should work

Workbench Repro

🙁 Actual behavior

Those functions accept only string to parse

🙂 Expected behavior

Should accept number, Number and bigInt too

Solution

I send a PR for this. please review and merge ❤️

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions