Skip to content

Number.isFinite is missing type guard #43792

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
Juraj-Masiar opened this issue Apr 23, 2021 · 1 comment
Closed

Number.isFinite is missing type guard #43792

Juraj-Masiar opened this issue Apr 23, 2021 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@Juraj-Masiar
Copy link

Bug Report

The Number.isFinite accepts unknown parameter and returns true only if the parameter is Number.
So there should be a type guard saying it's a Number.
MDN:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite

🔎 Search Terms

Number.isFinite

🕗 Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about Number.isFinite

⏯ Playground Link

Playground link with relevant code

💻 Code

function double(x: number | undefined): number {
  if (Number.isFinite(x)) {
    return x * 2;  // ERROR: Object is possibly 'undefined'.
  }
  return 0;
}

🙁 Actual behavior

ERROR: Object is possibly 'undefined'.

🙂 Expected behavior

No error :)

@MartinJohns
Copy link
Contributor

MartinJohns commented Apr 23, 2021

Duplicate of #39090. Found using the search terms you provided in your issue. This has been rejected with a fairly good reason already.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Apr 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants