正在加载视频...

视频加载失败

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

49,603 次观看 • 1 年前 •via X (Twitter)

11 条评论

Cory House 的头像
Cory House1 年前

Full course with code for 20% off:

Alexander Mia 的头像
Alexander Mia1 年前

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 🇨🇭 的头像
Pavel Svitek 🇨🇭1 年前

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

Cory House 的头像
Cory House1 年前

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

Artem Zakharchenko 的头像
Artem Zakharchenko1 年前

This is awesome!

Wildan 的头像
Wildan1 年前

nice use of never. learned a new thing!

ً 的头像
ً1 年前

should just do `pet satisfies never`

tom byrer 的头像
tom byrer1 年前

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

BDR 的头像
BDR1 年前

Great tip thanks!

Benjamin Scott 的头像
Benjamin Scott1 年前

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. 的头像
Niko E.1 年前

A realy good one.

相关视频