Skip to content
CodeWiki
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
Search
⌘K
English
English
Chinese
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
English
English
Chinese
Practice
/
Quiz
/
TypeScript
/
Type narrowing
Why pass a switch default value to assertNever instead of returning "unknown"?
from Type narrowing
TypeScript 6
intermediate
3 min
Why pass a switch default value to assertNever instead of returning "unknown"?
A newly added union member then produces a compile error until it gets a branch.
assertNever converts unknown runtime data into a valid union member.
It makes every switch branch run once.
It removes the discriminant from emitted JavaScript.
Check
Ask AI about this kata
Report an error
previous kata
A variable is declared as string | number and currently narrowed to string. Why may a lat…
Quiz
next kata
What does this program print?
Predict the output
A new version is available
Reload