Generic Inference

This lesson explains how TypeScript can infer a type.

Inference and generic #

Inference with generic is possible. If a function takes a parameter of type T and it returns T as well, the parameter assigned will define the generic type, and the return is inferred to be type T. The only exception is that if your function doesn’t use the value T, it will return an empty object type.

Get hands-on with 1400+ tech skills courses.