Skip to content

Latest commit

 

History

History
70 lines (65 loc) · 2.6 KB

type-predicate.md

File metadata and controls

70 lines (65 loc) · 2.6 KB

Type Predicate

A type predicate is a special kind of function return type. It tells the Typescript compiler what type a piece of data is.

// the `input is Value` is a type predicate
function isValue(input: unknown): input is Value;

The Typescript compiler relies heavily on type predicates to determine or not your code is safe to compile.

It's one of the features that attracted us to Typescript in the first place.