React Native TypeScript Transformer

1.2.13 · deprecated · verified Sun Apr 19

This package, `react-native-typescript-transformer`, provides a mechanism for transpiling TypeScript files within React Native applications. It functions by configuring the React Native packager (Metro) to use the TypeScript compiler directly for transformation, enabling seamless usage of TypeScript with React Native versions starting from 0.45. The current stable version is 1.2.13. However, it is largely considered superseded and deprecated for new projects or existing projects on React Native 0.57 and above, as modern React Native CLI (`react-native init --template typescript`) configures Babel for TypeScript transpilation by default. The key differentiator is its use of the TypeScript compiler for transpilation, unlike Babel which only strips types, requiring a separate `tsc --noEmit` command for type checking. Release cadence is infrequent, reflecting its deprecated status for current development practices.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart configures `tsconfig.json` and `metro.config.js` to enable TypeScript compilation for React Native >= 0.59 projects using this transformer, along with necessary dev dependencies.

{
  // tsconfig.json
  "compilerOptions": {
    "target": "es2015",
    "jsx": "react",
    "noEmit": true,
    "moduleResolution": "node",
    "importHelpers": true // Optional, for tslib
  },
  "exclude": [
    "node_modules"
  ]
}

// metro.config.js (for RN >= 0.59)
module.exports = {
  transformer: {
    babelTransformerPath: require.resolve('react-native-typescript-transformer')
  },
  resolver: {
    sourceExts: ['js', 'jsx', 'ts', 'tsx', 'json', 'node']
  }
};

// Add dev dependencies
// yarn add --dev react-native-typescript-transformer typescript @types/react @types/react-native

view raw JSON →