The problem is that TypeScript doesn't run at runtime, meaning that it doesn't know the value of the array. So in order to make this work, you have to cast it or do a Typeguard. Somebody messaged me and said TypeScript 5.2 fixes that, which is really nice. But I think there's a lot of annoying little things where any dev can look at that code and say, there's no possible situation where I can see that this would be a string. And unfortunately, yeah, that's the case in some use cases.

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