TypeScript is smarter than you in many of these regards and it's just looking out for you. I also ran into another thing with this the other day Typeguard which was I used a regular function but because functions are hoisted if there's a possibility that that could be called before you select the element so they have to check inside of the function again. One way to type guard is using a utility method so number dot is number that's actually not a method in JavaScript but you couldYou could go on NPM and grab a utility method You could use an is error method that specifically checks for it or is is not a number as well. If else statement if else statements will narrow for

Get the Snipd
podcast app

Unlock the knowledge in podcasts with the podcast player of the future.
App store bannerPlay store banner

AI-powered
podcast player

Listen to all your favourite podcasts with AI-powered features

Discover
highlights

Listen to the best highlights from the podcasts you love and dive into the full episode

Save any
moment

Hear something you like? Tap your headphones to save it with AI-generated key takeaways

Share
& Export

Send highlights to Twitter, WhatsApp or export them to Notion, Readwise & more

AI-powered
podcast player

Listen to all your favourite podcasts with AI-powered features

Discover
highlights

Listen to the best highlights from the podcasts you love and dive into the full episode