react
> TypeScript configuration for React libraries and apps with the modern JSX transform. Extends @jmlweb/tsconfig-base.
โจ Features
Section titled โโจ Featuresโ- โ๏ธ Modern JSX:
jsx: "react-jsx", noReactimport needed - ๐ DOM Types:
DOMandDOM.Iterablelibs - ๐ฆ Bundler Resolution:
module: "ESNext"withmoduleResolution: "bundler" - ๐ Strict Mode: inherits every strict flag from the base config
๐ฆ Installation
Section titled โ๐ฆ Installationโnpm install --save-dev @jmlweb/tsconfig-react @jmlweb/tsconfig-base typescript๐ Quick Start
Section titled โ๐ Quick Startโ{ "extends": "@jmlweb/tsconfig-react", "include": ["src"], "exclude": ["node_modules", "dist"]}๐ก Examples
Section titled โ๐ก ExamplesโVite app
Section titled โVite appโ{ "extends": "@jmlweb/tsconfig-react", "compilerOptions": { "noEmit": true }, "include": ["src"]}Component library with declarations
Section titled โComponent library with declarationsโ{ "extends": "@jmlweb/tsconfig-react", "compilerOptions": { "outDir": "./dist", "rootDir": "./src", "emitDeclarationOnly": true }, "include": ["src"], "exclude": ["**/*.test.tsx"]}๐ Configuration Details
Section titled โ๐ Configuration DetailsโExtends @jmlweb/tsconfig-base and overrides:
| Option | Value | Description |
|---|---|---|
jsx |
react-jsx |
Modern JSX transform |
module |
ESNext |
ES modules for bundlers |
moduleResolution |
bundler |
Bundler-style resolution |
lib |
["ES2022", "DOM", "DOM.Iterable"] |
ES2022 plus browser APIs |
Everything else (strict, target: ES2022, verbatimModuleSyntax, โฆ) comes from the base config.
jsx: react-jsx uses the automatic runtime (React 16.14+ / 17+).
๐ฏ When to Use
Section titled โ๐ฏ When to Useโ- โ React libraries and component packages
- โ React apps built with Vite, Rsbuild, esbuild or similar bundlers
- โ Projects that need DOM types
Next.js: use @jmlweb/tsconfig-nextjs. Node.js only: use @jmlweb/tsconfig-node.
๐ง Extending the Configuration
Section titled โ๐ง Extending the Configurationโ{ "extends": "@jmlweb/tsconfig-react", "compilerOptions": { "jsx": "react-jsxdev", "paths": { "@/*": ["./src/*"] } }}๐ Usage with Scripts
Section titled โ๐ Usage with Scriptsโ{ "scripts": { "typecheck": "tsc --noEmit" }}npm run typecheck๐ Requirements
Section titled โ๐ Requirementsโ- Node.js >= 22.12.0
- TypeScript >= 5.0.0
๐ฆ Peer Dependencies
Section titled โ๐ฆ Peer Dependenciesโ@jmlweb/tsconfig-base(^2.0.0)
typescript is not a declared peer; install it in your project.
๐ Related Packages
Section titled โ๐ Related Packagesโ@jmlweb/tsconfig-base- base config extended by this package@jmlweb/tsconfig-nextjs- extends this config for Next.js@jmlweb/oxlint-config-react- Oxlint configuration for React (recommended)@jmlweb/oxfmt-config-base- Oxfmt configuration (recommended)
๐ Migration Guide
Section titled โ๐ Migration Guideโ1.x โ 2.0.0
Section titled โ1.x โ 2.0.0โBreaking: Node.js >=22.12.0 is now required (Node.js 18 and 20 are end-of-life).
- Upgrade Node.js to 22.12.0 or later.
- Update the package:
npm install --save-dev @jmlweb/tsconfig-react@^2.0.0.
The compilerOptions are unchanged. See the Changelog.
๐ License
Section titled โ๐ LicenseโMIT