Using Typescript with React

When using Typescript with React you don’t need a lot of changes to your codebase.

First it’s the file extensions, you’d use .tsx for components and .ts for the rest of the files that would normally be .js files.

Most of the changes will represent applying types to component props, to state in components, to event handlers and some other areas.

Each of these topics are described in detail in the below links:

Typing props and state in React functional components

Typing props and state in React class based components

Typed events and refs in React components with Typescript