Loading video...

Video Failed to Load

Go Home

⚛️ How to use TypeScript type predicates in React to create a more robust, type-safe, and maintainable component. (this pattern is particularly useful when dealing with discriminated unions or when you need to narrow types based on runtime checks)

29,508 views • 1 year ago •via X (Twitter)

5 Comments

George Moller's profile picture
George Moller1 year ago

I've been working professionally with React for more than 8 years and I compiled all my knowledge into 100+ infographics and 70+ video tutorials just like this one. Check them out ↓

Andre de Waard's profile picture
Andre de Waard1 year ago

We don’t need this since TS 5.5 right?

Prasenjit's profile picture
Prasenjit1 year ago

Thank you for the check, it's going to be useful.

Pavel Romanov's profile picture
Pavel Romanov1 year ago

Strange, I've just tested it in TS playground and stackblitz React playground and it narrows the type correctly (with the latest TS version). Maybe it is a problem of some older TS version or less strict TS complier config?

Davide Briano's profile picture
Davide Briano1 year ago

This is automatically narrowed with the latest TS version now 👌🏻

Related Videos