- Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
Bug Report
π Search Terms
Number object
number primitive
binary operator <
ts2365
TypeScript 5.0-dev
π Version & Regression Information
- This changed between versions 4.9.5 and 5.0.0-dev.20230210
β― Playground Link
Playground link with relevant code
π» Code
const a = new Number(1); const b = 2; console.log(a < b)
π Actual behavior
In TypeScript 5.0.0-dev.20230210, it reports error ts2365
, but in TypeScript 4.9.5, it doesn't.
π Expected behavior
I'm not sure whether this is a bug of 5.0-dev or a breaking change that which will be introduced in 5.0. If it's a breaking change by design, maybe it should be included in #51362? If not, it should not report any error since it's valid JavaScript code.
Actually, I run into this error when I try to extend Number.prototype
for utility:
interface Number { [Symbol.iterator](): Generator<number>; } Number.prototype[Symbol.iterator] = function*() { for (let i = 0; i < this; i++) yield i; // ^^^^^^^^ ts2365 } for (const i of 10) console.log(i);
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug