4 ms·
The op did say they didn't want to do these type of checks. I thought the answer was 'instanceof'? https://www.typescriptlang.org/docs/handbook/2/narrowing.ht
by Incipient 7mo ago
The op did say they didn't want to do these type of checks.
I thought the answer was 'instanceof'?
https://www.typescriptlang.org/docs/handbook/2/narrowing.html#instanceof-narrowing https://www.typescriptlang.org/docs/handbook/2/narrowing.htm...
- culi 7mo agoI see what you mean, thanks. instanceof works if you're using javascript classes but not for "types". You can't do `instanceof Dog`. `instanceof` is a JavaScript feature https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...