Open ghost opened 2 years ago
I agree. That should be improved. I think we should do both suggestions.
@sindresorhus would you prefer the first suggestion to be a breaking change in @sindresorhus/is
or a special case added to ow
?
would you prefer the first suggestion to be a breaking change in @sindresorhus/is or a special case added to ow?
How would you fix it in @sindresorhus/is
?
@sindresorhus change https://github.com/sindresorhus/is/blob/v4.4.0/source/index.ts#L112-L113
to
case 'number':
return Number.isNaN(value) ? 'NaN' : 'number';
Ah yes. Let's fix it in @sindresorhus/is
, but it might take a while before we can do a major version there, so better to fix it in both places, actually.
Ok, ignore #232 then.
See comment update.
When testing
NaN
againstow.number
, the following error message is emitted:This behaviour can be verified by running this two line snippet in the Node REPL:
I think that this error message would be quite confusing for those who encounter it. I see two possible ways to solve this problem:
NaN
case to be something along the lines of:Expected argument to be of type `number`, but received `NaN`.
ow.number.nan
andow.number.not.nan
checks.