mobily / ts-belt

🔧 Fast, modern, and practical utility library for FP in TypeScript.
https://mobily.github.io/ts-belt
MIT License
1.08k stars 30 forks source link

`never` result from `isDate` when value is `unknown` #73

Open xiwcx opened 1 year ago

xiwcx commented 1 year ago

Hi i'm getting the following error:

Screenshot 2023-02-26 at 13 30 41 Screenshot 2023-02-26 at 13 30 51

from the following code:

const getValue = (value: unknown) => {
  if (G.isDate(value)) return value.toISOString().split("T")[0];
  if (G.isNumber(value)) return value.toString();

  return value;
};

i'm not certain this is an error, but if is the expected result i am uncertain of why. if i change the input type to any then isNumber gives me a never result:

Screenshot 2023-02-26 at 13 34 02
JUSTIVE commented 6 months ago

just curious, the current type of isDate is <A>(value:A) => value is Extract<A, Date>. why not just simply <A>(value:A) => value is Date? is there reason not to be?