Closed
Description
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 :)
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
MartinJohns commentedon 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.