Curriculum
Course: TypeScript
Login
Text lesson

Type: never

The never type essentially represents a value that never occurs, effectively causing an error if it is ever defined.

let x: never = true// Error: Type ‘boolean’ is not assignable to type ‘never’.

The never type is seldom used on its own and is primarily employed in advanced generics.

Type: undefined & null

undefined and null are types that correspond to the JavaScript primitives undefined and null, respectively.

let y: undefined = undefined;
let z: null = null;

These types are most useful when strictNullChecks is enabled in the tsconfig.json file.