interface (TypeScript)

In TypeScript, a named description of an object's shape: which properties it has and their types.

In more detail

An interface lists property names and their types, and a question mark marks a property as optional. TypeScript then reports an error wherever an object does not fit the shape.

Examples

Every lesson starts by declaring one, such as interface Token { $value: string; $type?: string }.
Storybook Autodocs reads component prop interfaces to build documentation.
interface User { id: string; email: string; isActive: boolean }

Related terms

Taught in

References