Number.is* should accept unknown
#34931
Labels
Bug
A bug in TypeScript
Domain: lib.d.ts
The issue relates to the different libraries shipped with TypeScript
Milestone
TypeScript Version: 3.8.0-dev.20191102
Search Terms: Number isInteger isSafeInteger isFinite isNaN
Code
Expected behavior:
Type checks
Actual behavior:
Fails to type check because
Number.isInteger
is typed to take onlynumber
.Playground Link:
http://www.typescriptlang.org/play/index.html?ts=3.8.0-dev.20191102&ssl=3&ssc=2&pln=1&pc=1#code/CYUwxgNghgTiAEAzArgOzAFwJYHtX2QGcQAKVZAWwCMQYAuec62gSgYDcctgBuAKFCRYCMHkIZ4FKAE8aAOUo168cTCyoA5vAA+jRbX5ZE8EguYwAdFkIBJVBhAbaJKbJBmlLFvADefeATELjLy+jDwUIR65iz8AL5AA
Related Issues:
isNaN
andisFinite
should accept number or string #4002 - not the same issue - that issue is about the global functions that coerce their argument, while this is about the functions onNumber
that don't, making it safe to widen the accepted types.The text was updated successfully, but these errors were encountered: