> For the complete documentation index, see [llms.txt](https://petercheng7788.gitbook.io/developer-note/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://petercheng7788.gitbook.io/developer-note/programming-language/typescript/type-vs-interface.md).

# Type vs Interface

## Type

* Use `type` when defining an alias for primitive types (string, boolean, number, bigint, symbol, etc)
* Use `type` when defining tuple types
* Use `type` when defining function types
* Use `type` when defining a union

```typescript
type Nullish = null | undefined;
type Fruit = 'apple' | 'pear' | 'orange';
type Num = number | bigint;
type row = [colOne: number, colTwo: string];
```

## Interface

* Use `interface` for all object types where using `type` is not required (see above)
* Using `interface` can extends from another interface, due to inheritance
