A base TSConfig for working with Create React App
npx @tessl/cli install tessl/npm-tsconfig--create-react-app@2.0.0A base TypeScript configuration specifically designed for Create React App projects. This package provides pre-configured TypeScript compiler options optimized for React development with Create React App toolchain, including DOM libraries, ESNext module resolution, JSX React transformation, and strict type checking.
npm install --save-dev @tsconfig/create-react-appThis package does not provide programmatic imports. Instead, it's used by extending the configuration in your TypeScript config file:
{
"extends": "@tsconfig/create-react-app/tsconfig.json"
}Install the package as a development dependency and extend it in your tsconfig.json:
npm install --save-dev @tsconfig/create-react-appCreate or update your tsconfig.json:
{
"extends": "@tsconfig/create-react-app/tsconfig.json",
"compilerOptions": {
// Optional: Override specific options
},
"include": [
"src/**/*"
]
}This package is part of the @tsconfig/* family of TypeScript configuration bases. Other popular configurations include:
All packages follow the same extension pattern and can be combined or overridden as needed.
Provides a complete TypeScript configuration base that can be extended in Create React App projects.
{
"extends": "@tsconfig/create-react-app/tsconfig.json"
}The base configuration includes the following compiler options:
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"lib": ["dom", "dom.iterable", "esnext"],
"module": "esnext",
"moduleResolution": "bundler",
"target": "es2015",
"allowJs": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"isolatedModules": true,
"jsx": "react-jsx",
"noEmit": true,
"noFallthroughCasesInSwitch": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true
}
}Override specific compiler options while maintaining the base configuration.
{
"extends": "@tsconfig/create-react-app/tsconfig.json",
"compilerOptions": {
"target": "es2017",
"strict": false,
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
}
}Add custom path mappings for module resolution:
{
"extends": "@tsconfig/create-react-app/tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@components/*": ["src/components/*"],
"@utils/*": ["src/utils/*"],
"@assets/*": ["src/assets/*"]
}
}
}Specify which files to include or exclude from compilation:
{
"extends": "@tsconfig/create-react-app/tsconfig.json",
"include": [
"src/**/*",
"custom-types/**/*"
],
"exclude": [
"src/**/*.test.ts",
"src/**/*.spec.ts"
]
}{
"lib": ["dom", "dom.iterable", "esnext"]
}{
"module": "esnext",
"moduleResolution": "bundler",
"target": "es2015"
}{
"jsx": "react-jsx",
"allowJs": true
}{
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"resolveJsonModule": true
}{
"isolatedModules": true,
"noEmit": true,
"skipLibCheck": true
}{
"strict": true,
"noFallthroughCasesInSwitch": true
}The configuration follows the standard TypeScript configuration schema:
interface TSConfig {
$schema?: string;
extends?: string | string[];
compilerOptions?: CompilerOptions;
include?: string[];
exclude?: string[];
files?: string[];
}
interface CompilerOptions {
lib?: string[];
module?: string;
moduleResolution?: string;
target?: string;
allowJs?: boolean;
allowSyntheticDefaultImports?: boolean;
esModuleInterop?: boolean;
isolatedModules?: boolean;
jsx?: string;
noEmit?: boolean;
noFallthroughCasesInSwitch?: boolean;
resolveJsonModule?: boolean;
skipLibCheck?: boolean;
strict?: boolean;
baseUrl?: string;
paths?: Record<string, string[]>;
}Most common usage for a typical Create React App project:
{
"extends": "@tsconfig/create-react-app/tsconfig.json",
"include": [
"src"
]
}For monorepo setups with shared types:
{
"extends": "@tsconfig/create-react-app/tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@shared/*": ["../shared/src/*"]
}
}
}Separate configuration for test files:
{
"extends": "@tsconfig/create-react-app/tsconfig.json",
"compilerOptions": {
"types": ["jest", "@testing-library/jest-dom"]
},
"include": [
"src/**/*",
"**/*.test.ts",
"**/*.spec.ts"
]
}