# Type Aliases vs Interfaces — TypeScript

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

> Two ways to name a type, with small but real differences.

## 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

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