@total-typescript/tsconfig

repository·main·Indexed 22 days ago

https://github.com/total-typescript/tsconfig

A collection of curated TypeScript configurations based on Total TypeScript's TSConfig Cheat Sheet. It provides pre-configured base settings for various project types, including apps and libraries, with specific paths for bundler or tsc transpilation and DOM or non-DOM environments.

Tokens
998
Snippets
4
Records
4
Agent score
28%

What's inside @total-typescript/tsconfig

  1. Choose and apply a TSConfig base

    main

    To use a configuration, identify your project type and add the corresponding extends property to your tsconfig.json.

    Decision Logic

    1. Are you using tsc to transpile .ts to .js?

      • If Yes: Use the /tsc/ path prefix.
      • If No (e.g., using Vite, Remix, Astro, Nuxt): Use the /bundler/ path prefix.
    2. Does your code run in the DOM?

      • If Yes: Use the /dom/ segment.
      • If No (e.g., Node.js): Use the /no-dom/ segment.
    3. What is the project structure?

      • App: Use /app.
      • Library: Use /library.
      • Library in a Monorepo: Use /library-monorepo.
    // Example: Building an app that runs in the DOM with an external bundler
    {
      "extends": "@total-typescript/tsconfig/bundler/dom/app"
    }
  2. Configure `jsx` and `outDir` in your TSConfig

    main

    The base configurations do not cover certain specific options. You can override or add these in your local tsconfig.json under compilerOptions.

    • jsx: Set this if your app uses JSX (e.g., "jsx": "react-jsx").
    • outDir: Set this if you are using tsc and want to specify the output directory for compiled files.
    // Configuring JSX
    {
      "extends": "@total-typescript/tsconfig/bundler/dom/app",
      "compilerOptions": {
        "jsx": "react-jsx"
      }
    }
    
    // Configuring outDir for tsc
    {
      "extends": "@total-typescript/tsconfig/tsc/no-dom/library",
      "compilerOptions": {
        "outDir": "dist"
      }
    }
  3. Reference: List of available TSConfigs

    main

    Select the appropriate configuration path based on your environment and project type.

    // If using 'tsc' to transpile:
    // DOM
    "extends": "@total-typescript/tsconfig/tsc/dom/app",
    "extends": "@total-typescript/tsconfig/tsc/dom/library",
    "extends": "@total-typescript/tsconfig/tsc/dom/library-monorepo",
    
    // No DOM (e.g. Node.js)
    "extends": "@total-typescript/tsconfig/tsc/no-dom/app",
    "extends": "@total-typescript/tsconfig/tsc/no-dom/library",
    "extends": "@total-typescript/tsconfig/tsc/no-dom/library-monorepo"
    
    // If using an external bundler (Vite, Remix, etc):
    // DOM
    "extends": "@total-typescript/tsconfig/bundler/dom/app",
    "extends": "@total-typescript/tsconfig/bundler/dom/library",
    "extends": "@total-typescript/tsconfig/bundler/dom/library-monorepo",
    
    // No DOM (e.g. Node.js)
    "extends": "@total-typescript/tsconfig/bundler/no-dom/app",
    "extends": "@total-typescript/tsconfig/bundler/no-dom/library",
    "extends": "@total-typescript/tsconfig/bundler/no-dom/library-monorepo"