Type Vs Interface In Typescript Identifying Which One To Use

Both types and interface in typescript can be use to type object where the confusion comes in ,especially for those people that are new to typescript is identifying when to use them.

A generally rule of thumb will be to use

  1. to use type for your React Component Props and State, for consistency and because it is more constrained.

2 . always use interface for public API's definition when authoring a library or 3rd party ambient type definitions, as this allows a consumer to extend them via declaration merging if some definitions are missing.

Below is a table showing comparising between the two types.jpeg