# Type Aliases vs Interfaces — TypeScript Fundamentals

Source: https://www.skillbyai.com/en/typescript/ts-type-aliases-vs-interfaces

> Compare type aliases and interfaces, including extends, intersections and declaration merging, and pick the right one.

## Type aliases

`type` gives a name to **any** type — objects, unions, tuples, primitives.

```typescript
type Point = { x: number; y: number };
type Id = string | number;

const origin: Point = { x: 0, y: 0 };
```

## extends vs &

Interfaces combine with `extends` and can be **re-opened** later (declaration merging). Type aliases combine with `&` (intersection) and can't be reopened once declared.

## Which to pick

Default to `interface` for object shapes (especially public APIs); reach for `type` when you need unions, tuples or computed types.

**Quiz:** Which of these can name a union type like `string | number`?

- [ ] interface only
- [x] type only
- [ ] Neither
- [ ] `enum` only

*Answer:* type only. Interfaces can only describe object shapes; unions need a `type` alias.
