Up and Running with React Native and TypeScript
Quick and modern guide to getting started with React Native and TypeScript
In this post, I will go over how to quickly add TypeScript to a React Native project.
TypeScript is being picked up by a lot of projects these days. It gives JavaScript static typing, and helps simplify relations between various components.
In our project, we will automatically compile our TypeScript into ready to run JavaScript whenever we save a file in our text editor.
To check out the final boilerplate, click here.
This project assumes that you already have React Native CLI setup and working on your machine
The first thing we will do is create a new React Native project:
react-native init rntypescript
After the project is created, cd into the directory
cd rntypescript
The next thing we need to do is make sure we have TypeScript installed globally on our machine:
npm i -g typescript
Now, we need to go ahead and install the types we will be needing for React and React Native.
These types give us declaration files for both React and React Native.