logoalt Hacker News

culitoday at 12:19 AM1 replyview on HN

Your first code block works exactly as you would expect and has been working like that for many years

https://www.typescriptlang.org/play/?#code/C4TwDgpgBAIg9gcyg...


Replies

Incipienttoday at 1:39 AM

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.htm...

show 1 reply