We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The type for Math.sign is currently (x: number): number as seen in https://github.com/Microsoft/TypeScript/blob/master/lib/lib.es6.d.ts#L4177
Math.sign
(x: number): number
Its type could be (x: number): -1 | 0 | 1 instead.
(x: number): -1 | 0 | 1
That would allow for more specific typing in app code without having to wrap Math.sign.
The text was updated successfully, but these errors were encountered:
This would be great but
Math.sign(NaN) // NaN typeof NaN // "number"
which poisons what would otherwise be quite elegant behavior.
Sorry, something went wrong.
discussed previously in #15356
Thank you for your immediate response!
I had never considered what happens with NaN. Now I understand why it's return type is currently number.
NaN
number
I'll continue wrapping it for my comparators then.
No branches or pull requests
The type for
Math.sign
is currently(x: number): number
as seen inhttps://github.com/Microsoft/TypeScript/blob/master/lib/lib.es6.d.ts#L4177
Its type could be
(x: number): -1 | 0 | 1
instead.That would allow for more specific typing in app code without having to wrap
Math.sign
.The text was updated successfully, but these errors were encountered: