Type inference

Type inference is the compiler's ability to deduce the type of a variable or a function's return value from its value, without an explicit annotation. It lightens the code while keeping static checking. In practice, you mainly annotate function parameters and public APIs.

Example

const total = 12.5; // inferred: number
const noms = ['a', 'b']; // inferred: string[]

Related concepts

The whole glossary