Skip to content
This repository was archived by the owner on Jun 11, 2019. It is now read-only.

Files

Latest commit

 

History

History
33 lines (23 loc) · 897 Bytes

File metadata and controls

33 lines (23 loc) · 897 Bytes

Babel Preset: React Native TypeScript

A babel preset for React Native, using TypeScript instead of Flow.

This module works as a drop in replacement for babel-preset-react-native, but switches out the transform-flow-strip-types plugin for transform-typescript.

Note that the TypeScript transform plugin is new in Babel 7, and thus this preset only works with Babel 7 and newer, which is included with React Native 0.56 and newer.

Installation

npm install --save-dev babel-preset-react-native-typescript

Usage

In your .babelrc:

{
  "presets": ["react-native-typescript"]
}

In order to use the .ts and .tsx extension, you also need to configure React Native to look for those files. In your rn-cli.config.js:

module.exports = {
  getSourceExts () {
    return ['ts', 'tsx']
  },
}