Type vs Interface
Type
Use
typewhen defining an alias for primitive types (string, boolean, number, bigint, symbol, etc)Use
typewhen defining tuple typesUse
typewhen defining function typesUse
typewhen defining a union
type Nullish = null | undefined;
type Fruit = 'apple' | 'pear' | 'orange';
type Num = number | bigint;
type row = [colOne: number, colTwo: string];Interface
Use
interfacefor all object types where usingtypeis not required (see above)Using
interfacecan extends from another interface, due to inheritance
Last updated
Was this helpful?