Better error handling with unknown type in TypeScript

Опубликовано: 26 Февраль 2025
на канале: TypeScript with Benny Code
5,460
130

Improve your error handling in catch clauses by using TypeScript's unknown type.

My FREE programming apps:
https://apps.apple.com/app/id659282498
https://play.google.com/store/apps/de...

My FREE TypeScript Course:
https://typescript.tv/

Timeline:
00:00 Typing errors in try-catch
01:35 Type Guard Definition
01:55 instanceof Type Guard
02:17 Handle custom errors
04:30 typeof Type Guard
05:26 in Type Guard
06:36 Custom Type Guard
09:41 any vs. unknown
10:01 Compiler option for unknown

Code:
➜ https://gist.github.com/bennycode/92c...

Resources:
➜ https://typescript.tv/errors/
➜ https://www.typescriptlang.org/tsconf...

Follow TypeScript TV:
🌐 https://typescript.tv
🐦   / typescripttv  
📺    / typescripttv​  

Hashtags:
#TypeScript #JavaScript #Programming