Skip to content

react

npm version License: MIT Node.js TypeScript

> TypeScript configuration for React libraries and apps with the modern JSX transform. Extends @jmlweb/tsconfig-base.

  • โš›๏ธ Modern JSX: jsx: "react-jsx", no React import needed
  • ๐ŸŒ DOM Types: DOM and DOM.Iterable libs
  • ๐Ÿ“ฆ Bundler Resolution: module: "ESNext" with moduleResolution: "bundler"
  • ๐Ÿ”’ Strict Mode: inherits every strict flag from the base config
Terminal window
npm install --save-dev @jmlweb/tsconfig-react @jmlweb/tsconfig-base typescript
{
"extends": "@jmlweb/tsconfig-react",
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
{
"extends": "@jmlweb/tsconfig-react",
"compilerOptions": {
"noEmit": true
},
"include": ["src"]
}
{
"extends": "@jmlweb/tsconfig-react",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src",
"emitDeclarationOnly": true
},
"include": ["src"],
"exclude": ["**/*.test.tsx"]
}

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+).

  • โœ… 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.

{
"extends": "@jmlweb/tsconfig-react",
"compilerOptions": {
"jsx": "react-jsxdev",
"paths": {
"@/*": ["./src/*"]
}
}
}
{
"scripts": {
"typecheck": "tsc --noEmit"
}
}
Terminal window
npm run typecheck
  • Node.js >= 22.12.0
  • TypeScript >= 5.0.0
  • @jmlweb/tsconfig-base (^2.0.0)

typescript is not a declared peer; install it in your project.

Breaking: Node.js >=22.12.0 is now required (Node.js 18 and 20 are end-of-life).

  1. Upgrade Node.js to 22.12.0 or later.
  2. Update the package: npm install --save-dev @jmlweb/tsconfig-react@^2.0.0.

The compilerOptions are unchanged. See the Changelog.

MIT