Full Stack Radio cover image

144: Gary Bernhardt - TypeScript and Testing

Full Stack Radio

00:00

Is There a Name Property on the Group Classof?

When you say, if name in this object, it knows that only one of the two sides of that union. So what are the other ways that you would make that sort of check? We don't wan to use type, because it's not actually a type. The traditional property that's used to distinguish between different sides of a union is kind. If can own things, dot, kind equals user. Inside of that conditional, it's the same thing. It's narrowed to a user. And then in the else branch, it will be automatically narrowed too, to a group. You need to be able to express this, and typescript just totally allows you to do that

Play episode from 01:02:02
Transcript

The AI-powered Podcast Player

Save insights by tapping your headphones, chat with episodes, discover the best highlights - and more!
App store bannerPlay store banner
Get the app