Default TypeScript configuration for React Native apps
npx @tessl/cli install tessl/npm-react-native--typescript-config@0.81.0React Native TypeScript Config is a configuration package that provides a default TypeScript configuration (tsconfig.json) specifically optimized for React Native applications. It includes carefully configured compiler options targeting modern JavaScript (ESNext), with JSX support for React Native, strict type checking enabled, and module resolution settings optimized for the React Native bundler environment.
npm install @react-native/typescript-configThis package does not export TypeScript/JavaScript modules. Instead, it provides a TypeScript configuration file that is referenced in a project's tsconfig.json:
{
"extends": "@react-native/typescript-config"
}Create or update your project's tsconfig.json to extend the React Native configuration:
{
"extends": "@react-native/typescript-config",
"compilerOptions": {
// Override any specific options for your project
"baseUrl": "./src"
},
"include": [
"src/**/*"
]
}The configuration will automatically inherit all the React Native-optimized TypeScript settings.
Provides a complete TypeScript configuration optimized for React Native development.
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "React Native",
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"types": ["jest"],
"lib": [
"es2019",
"es2020.bigint",
"es2020.date",
"es2020.number",
"es2020.promise",
"es2020.string",
"es2020.symbol.wellknown",
"es2021.promise",
"es2021.string",
"es2021.weakref",
"es2022.array",
"es2022.object",
"es2022.string"
],
"allowJs": true,
"jsx": "react-native",
"noEmit": true,
"isolatedModules": true,
"strict": true,
"moduleResolution": "bundler",
"customConditions": ["react-native"],
"allowImportingTsExtensions": true,
"allowArbitraryExtensions": true,
"resolveJsonModule": true,
"resolvePackageJsonImports": false,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"skipLibCheck": true,
// Causes issues with package.json "exports"
"forceConsistentCasingInFileNames": false
},
"exclude": [
"**/Pods/**"
]
}Modern JavaScript Target: Targets ESNext for modern JavaScript features while maintaining React Native compatibility.
React Native JSX: Configured with "jsx": "react-native" for proper JSX transformation in React Native projects.
Type Checking: Enables strict type checking with "strict": true for better code quality and error prevention.
Module Resolution: Uses "moduleResolution": "bundler" optimized for the React Native Metro bundler.
Library Support: Includes ES2019-ES2022 feature libraries and Jest type definitions for comprehensive development support.
React Native Optimizations:
Build Optimization:
"noEmit": true - Prevents TypeScript from emitting compiled files (handled by React Native bundler)"isolatedModules": true - Ensures each file can be transpiled in isolation"skipLibCheck": true - Skips type checking of library files for faster buildsPlatform Exclusions: Excludes iOS Pods directory (**/Pods/**) from type checking.
The package is designed to be extended or overridden in consuming projects:
{
"extends": "@react-native/typescript-config",
"compilerOptions": {
// Project-specific overrides
"baseUrl": "./src",
"paths": {
"@/*": ["*"]
}
},
"include": [
"src/**/*",
"types/**/*"
],
"exclude": [
"node_modules",
"android",
"ios",
"**/*.test.ts"
]
}This package does not export TypeScript types as it is purely a configuration package. The configuration itself defines the TypeScript compilation behavior for React Native projects.
For a new React Native project created with React Native CLI or Expo:
{
"extends": "@react-native/typescript-config"
}When migrating an existing JavaScript React Native project to TypeScript:
Install the configuration package:
npm install --save-dev @react-native/typescript-configCreate or update tsconfig.json:
{
"extends": "@react-native/typescript-config",
"include": [
"src/**/*",
"App.tsx"
]
}Rename .js files to .ts or .tsx as appropriate.
In a monorepo with multiple React Native projects:
{
"extends": "@react-native/typescript-config",
"compilerOptions": {
"baseUrl": "../../",
"paths": {
"@shared/*": ["packages/shared/src/*"]
}
}
}