TypeScript · Types and shapes

Type alias

Gives a name to any type, including unions and tuples. Aliases are erased at build time.

Syntax
type User = { id: string }

Example

Example
type User = { id: string; name: string };
const user: User = { id: "u1", name: "Ada" };

More in this group

any Array types enums Function type Interface Literal type never null and undefined

Learn this in the course

Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.

Open the course