Search⌘ K

Adding React and TypeScript

Explore how to add React and TypeScript to your project manually by installing core libraries and setting up the TypeScript configuration file. Understand important compiler options and create a root React component with TypeScript to prepare for further development.

Adding React #

We can install React into our project by running the following command in the terminal:

npm install react react-dom

This installs the core React library as well the React library for interacting with the browser.

Adding TypeScript #

TypeScript can be installed in our project as a development dependency by running the following command in the terminal:

npm install --save-dev typescript 

Why do you think we have installed TypeScript as a development dependency rather than a full dependency that is available at runtime?

TypeScript is configured with a file called tsconfig.json. Let’s create this file in the root of our project with the ...