AI-powered
podcast player
Listen to all your favourite podcasts with AI-powered features
TypeScript's Problem With Filtering Strings
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.