Use TypeScript Config Generator

Enter your data below to use the TypeScript Config Generator

📌 Try these examples:
RESULT

Last updated

TypeScript Config Generator Examples

The TypeScript Config Generator creates customized tsconfig.json files for different project types. Below are practical examples for Node.js backends, React frontends, libraries, and strict configurations.

Node.js Backend (CommonJS)

{
  "compilerOptions": {
    "target": "ES2022",
    "module": "CommonJS",
    "moduleResolution": "node",
    "lib": ["ES2022"],
    "outDir": "./dist",
    "rootDir": "./src",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "resolveJsonModule": true,
    "declaration": false,
    "sourceMap": true
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "dist", "**/*.test.ts"]
}

Node.js Backend (ESM)

{
  "compilerOptions": {
    "target": "ES2022",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "lib": ["ES2022"],
    "outDir": "./dist",
    "rootDir": "./src",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "resolveJsonModule": true,
    "sourceMap": true
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "dist"]
}

React Frontend (Vite)

{
  "compilerOptions": {
    "target": "ES2020",
    "useDefineForClassFields": true,
    "lib": ["ES2020", "DOM", "DOM.Iterable"],
    "module": "ESNext",
    "moduleResolution": "bundler",
    "allowImportingTsExtensions": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx",
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noFallthroughCasesInSwitch": true,
    "skipLibCheck": true
  },
  "include": ["src"],
  "references": [{ "path": "./tsconfig.node.json" }]
}

TypeScript Library (npm Package)

{
  "compilerOptions": {
    "target": "ES2018",
    "module": "CommonJS",
    "moduleResolution": "node",
    "lib": ["ES2018"],
    "outDir": "./dist",
    "rootDir": "./src",
    "strict": true,
    "declaration": true,
    "declarationMap": true,
    "sourceMap": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts"]
}

Strict Mode Configuration

{
  "compilerOptions": {
    // The 'strict' flag enables all of these:
    "strict": true,

    // Individual strict flags (enabled by 'strict'):
    "strictNullChecks": true,        // null/undefined must be handled explicitly
    "strictFunctionTypes": true,     // stricter function type checking
    "strictBindCallApply": true,     // stricter bind/call/apply checking
    "strictPropertyInitialization": true, // class properties must be initialized
    "noImplicitAny": true,           // error on implicit 'any' type
    "noImplicitThis": true,          // error on implicit 'this' type
    "alwaysStrict": true,            // emit 'use strict' in output

    // Additional strictness (not included in 'strict'):
    "noUnusedLocals": true,          // error on unused local variables
    "noUnusedParameters": true,      // error on unused function parameters
    "noImplicitReturns": true,       // error if not all paths return a value
    "noFallthroughCasesInSwitch": true, // error on switch fallthrough
    "exactOptionalPropertyTypes": true  // stricter optional property handling
  }
}

Path Aliases Configuration

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@/*": ["src/*"],
      "@components/*": ["src/components/*"],
      "@utils/*": ["src/utils/*"],
      "@types/*": ["src/types/*"],
      "@hooks/*": ["src/hooks/*"],
      "@api/*": ["src/api/*"]
    }
  }
}

// Usage in code:
import { Button } from '@components/Button';
import { formatDate } from '@utils/date';
import type { User } from '@types/user';

// Note: Also configure your bundler (Vite/webpack) to resolve these aliases:
// vite.config.ts:
import { defineConfig } from 'vite';
import path from 'path';

export default defineConfig({
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
      '@components': path.resolve(__dirname, './src/components'),
    }
  }
});

Incremental TypeScript Adoption (JS + TS)

{
  "compilerOptions": {
    "target": "ES2020",
    "module": "CommonJS",
    "allowJs": true,           // allow .js files
    "checkJs": false,          // don't type-check .js files yet
    "strict": false,           // start permissive
    "noImplicitAny": false,    // allow implicit any initially
    "skipLibCheck": true,
    "esModuleInterop": true,
    "outDir": "./dist",
    "rootDir": "./src"
  },
  "include": ["src/**/*"]
}

// Gradually increase strictness:
// Phase 1: allowJs: true, checkJs: false, strict: false
// Phase 2: allowJs: true, checkJs: true, strict: false
// Phase 3: allowJs: false, strict: true (all files converted to TS)

Monorepo Configuration

# Root tsconfig.json (base config)
{
  "compilerOptions": {
    "target": "ES2020",
    "module": "CommonJS",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  }
}

# packages/api/tsconfig.json (extends root)
{
  "extends": "../../tsconfig.json",
  "compilerOptions": {
    "outDir": "./dist",
    "rootDir": "./src",
    "declaration": true
  },
  "include": ["src/**/*"]
}

# packages/web/tsconfig.json (extends root)
{
  "extends": "../../tsconfig.json",
  "compilerOptions": {
    "lib": ["ES2020", "DOM"],
    "jsx": "react-jsx",
    "noEmit": true
  },
  "include": ["src/**/*"]
}

Target and Lib Reference

// Target: what JavaScript version to output
// ES5:    IE11, very old browsers (no arrow functions, no const/let)
// ES2015: Modern browsers, Node.js 6+
// ES2017: async/await natively
// ES2018: Rest/spread for objects
// ES2020: Optional chaining, nullish coalescing
// ES2022: Top-level await, class fields
// ESNext: Latest features

// Lib: what type definitions to include
// ES2020:     JavaScript standard library
// DOM:        Browser APIs (window, document, fetch)
// DOM.Iterable: Iterable DOM collections
// WebWorker: Web Worker APIs

Common Compiler Options Reference

Use the TypeScript Config Generator to select your project type and options, then get a complete, commented tsconfig.json ready to use.

Frequently Asked Questions

Simply enter your data, click the process button, and get instant results. All processing happens in your browser for maximum privacy and security.

Yes! TypeScript Config Generator is completely free to use with no registration required. All processing is done client-side in your browser.

Absolutely! All processing happens locally in your browser. Your data never leaves your device, ensuring complete privacy and security.