Tsallaka zuwa abun ciki
Justice Tech School

Type Aliases

type gives a name to any type. Use it for unions, tuples and object shapes.

Example
type ID = string | number;
type Point = { x: number; y: number };
const p: Point = { x: 1, y: 2 };
const id: ID = 7;
console.log(p, id);

Result

{
  x: 1,
  y: 2,
} 7

Exercise

Name a type.

 ID = number;

Quiz Test

What does type create?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.