Interview Q&A / TypeScript

INTERVIEW Q&A · 47 QUESTIONS

TypeScript interview questions

Types, interfaces, generics and safe patterns for real codebases.

  1. What is the never type in TypeScript, and how do you use it for exhaustive checks?

    never is the type with no possible values. It is the return type of functions that never finish normally, like one that always throws, and it is what remains after every case of a union has been handled. Assigning the leftover value to never makes the compiler report any case you forgot.

    AdvancedIn-depth4 min read