Loading video...

Video Failed to Load

Go Home

Problem: I want to ensure my switch statement handles all potential cases. Solution: Use TypeScript's never type. Here's how:

49,603 views • 1 year ago •via X (Twitter)

11 Comments

Cory House's profile picture
Cory House1 year ago

Full course with code for 20% off:

Alexander Mia's profile picture
Alexander Mia1 year ago

INTRODUCING: Agentic Security - LLM Security Scanner! 🔍 🔑 Features: Scans for prompt injections, jailbreaking & more. Provides detailed reports & options to customize attack rules. 🔗access the GitHub Link ↓

Pavel Svitek 🇨🇭's profile picture
Pavel Svitek 🇨🇭1 year ago

Great tip.. this is a really good lib to handle these kind of issues

Cory House's profile picture
Cory House1 year ago

Feel unnecessary to me, but I can see how one might prefer it

Artem Zakharchenko's profile picture
Artem Zakharchenko1 year ago

This is awesome!

Wildan's profile picture
Wildan1 year ago

nice use of never. learned a new thing!

ً's profile picture
ً1 year ago

should just do `pet satisfies never`

tom byrer's profile picture
tom byrer1 year ago

Or, if you have nested switch/if statements inside of your switch, use a Finite State Machine ;)

BDR's profile picture
BDR1 year ago

Great tip thanks!

Benjamin Scott's profile picture
Benjamin Scott1 year ago

Ah so that’s why “never” pops up every now and then To be honest, I’ve always hated seeing it but never understood it until recently

Niko E.'s profile picture
Niko E.1 year ago

A realy good one.

Related Videos