These configs are based in setup.js
and package.json
from React Native Template Typescript.
-
If you starting your project now, I recommend to use the typescript template, with the following command:
react-native init MyApp --template typescript
-
Keep the root
index.js
file with.js
extension. -
If you use PropTypes before the migration, you can delete its package running:
yarn remove prop-types
-
Keep in mind that you have to add
@types
declarations for most libs you add. Some libs already has types out of the box, like Redux and NativeBase. For these, there's no need to add a@types
dependency. Others need to add@types
dependecy, like React (@types/react
) and React-Native-FBSDK (@types/react-native-fbsdk
). And some others have no type declarations, like Reactotron-Redux. For these, you have to add type declarations manually. To make it, add a file that has.d.ts
extension anywhere in yoursrc
folder, with:declare module 'name-of-module' { // here you can add things that you can use }
Some IDEs, like VSCode, do it automatically if you choose it.