Table of contents
- 1. Video
- 2. Final Code
- 3. Summary
In this tutorial Benny shows you simple techniques on how to improve your switch statements. Using the tips and tricks from the video, you will never miss a switch case again. You will also learn how to fix error TS2322, TS2366 and TS7030.
Errors fixed in the video:
TS2322: Type ‘undefined’ is not assignable to type ‘number’.
TS2366: Function lacks ending return statement and return type does not include ‘undefined’.
TS7030: Not all code paths return a value.
- Create a switch case for every valid value
- Define a custom return type to narrow your function’s return values
- Create a