Search⌘ K

Function and Inference Variables

Explore how TypeScript infers types for function variables, enabling you to write strongly typed anonymous functions without explicit type annotations. Understand parameter type matching within interfaces and the rules for literal type inference starting from TypeScript 2.1.

We'll cover the following...

TypeScript can infer the type of a variable, hence, it is possible to avoid using the colon for anonymous functions by simply setting the variable to an unnamed function that has type parameters and a return type. ...