3 ms·
I mean, that could be changed. Currently: either string OR number Possible: either string | number OR just number
by HeavyFeather 4y ago
I mean, that could be changed.
Currently: either string OR number
Possible: either string | number OR just number
- deleted 4y ago[deleted]
- yencabulator 4y ago"string | number | number" is just "string | number" to Typescript.
- benatkin 4y agoThe OR doesn't indicate | in TypeScript, it indicates the result of the possible future type guard.
- schwartzworld 4y ago> The OR doesn't indicate | in TypeScript, it indicates the result of the possible future type guard. Are you implying in your other comment (that HN won't let me reply to) that Typescript has an "OR" operator that is distinct from "|"? Can you link to documentation on that?
- HeavyFeather 4y ago"OR" was just my (bad) way to explain it. In plain English: if isInteger(x) is true, x is definitely a `number` if isInteger(x) is false, x is unknown/unaltered (it remains `typeof x`) Current type guards can't express "yes versus maybe", so isInteger cannot be a type guard at all.