A starter for React Native with TypeScript transpiled by Babel 7 and jest for tests.
Since React Native 0.56.0 Babel 7 is used which supports TypeScript out of the box.
-
Update to RN 0.56.0:
react-native-git-upgrade 0.56.0-rc.4
-
Update babel-preset-react-native to ^5.0.1 or newer (as per RN Changelog instructions).
yarn upgrade babel-preset-react-native@^5.0.1
-
Add TypeScript dependencies.
yarn add --dev typescript @types/react @types/react-dom
-
Configure TypeScript.
Edit rn-cli.config.js Edit tsconfig.json mv App.js App.tsx
-
Convert .babelrc to babel.config.js. See babel/babel#7358
SyntaxError: node_modules/react-native/Libraries/Utilities/Platform.ios.js: Unexpected token, expected "{" (35:17)
-
Configuring jest.
yarn add --dev @types/jest Add jest config to package.json mv App.ts into src/ or otherwise it seems the babel.config.js is not used (SyntaxError: Unexpected token import)