TS Config (tsconfig.json)

Notes & Setup

Aaron's Personal Preference

...

Additional Options
  1. noEmit (Do Not Emit Outputs):

    • Description: Prevents the compiler from generating output files like JavaScript source code or .d.ts declaration files.

    • Popular Use: "noEmit": true is often used in projects where TypeScript is used only for type checking, such as in some frontend projects where a different build tool is responsible for generating the final JavaScript.

  2. noEmitOnError (No Emit on Error):

    • Description: Ensures no output files are generated if any errors are reported.

    • Popular Use: "noEmitOnError": true is useful to ensure that builds do not proceed with errors, which is particularly important in CI/CD pipelines.

  3. strictNullChecks (Strict Null Checking):

    • Description: When enabled, null and undefined are only assignable to their own types and any.

    • Popular Use: "strictNullChecks": true is crucial for robust type checking, helping to avoid common bugs related to null references.

  4. noImplicitReturns (No Implicit Returns in Functions):

    • Description: Ensures that all code paths in a function explicitly return a value.

    • Popular Use: "noImplicitReturns": true is used to improve code readability and maintainability by making return patterns explicit.

  5. noUnusedLocals and noUnusedParameters (No Unused Variables and Parameters):

    • Description: Report errors on unused local variables and function parameters.

    • Popular Use:

      • "noUnusedLocals": true and "noUnusedParameters": true are helpful in maintaining clean code, free from unused or redundant code.

  6. resolveJsonModule (Import JSON Modules):

    • Description: Allows importing .json files directly in TypeScript files.

    • Popular Use: "resolveJsonModule": true enables working with JSON files just as you would with TypeScript modules, which can be particularly useful when dealing with configuration files or data.

  7. isolatedModules (Transpile Each File as a Separate Module):

    • Description: Ensures each file can be safely transpiled without relying on the types from other files.

    • Popular Use: "isolatedModules": true is often used in projects where the code needs to be compatible with transpilers like Babel.

  8. downlevelIteration (More Accurate Iteration Support):

    • Description: Provides more accurate support for iterating ES2015 structures in downleveled versions of ECMAScript.

    • Popular Use: "downlevelIteration": true is useful when targeting older ECMAScript standards but still wanting to use newer syntax like for...of loops over new types like Set or Map.

  9. composite (Project References):

    • Description: Enables project references, allowing TypeScript to use builds from other projects.

    • Popular Use: "composite": true is used in larger projects or monorepos where you want to split your code into multiple TypeScript projects and reference them.

  10. incremental (Enable Incremental Compilation):

    • Description: Allows TypeScript to save information about the project graph from the last compilation to speed up subsequent compilations.

    • Popular Use: "incremental": true significantly improves the build times in larger projects by only recompiling what's necessary.

  11. baseUrl and paths (Base URL and Path Mapping):

    • Description:

      • baseUrl sets the base directory for non-relative module names.

      • paths specifies a series of entries that re-map imports to lookup locations relative to the baseUrl.

    • Popular Use:

      • "baseUrl": "." and defining paths are commonly used to set up custom path aliases, making imports cleaner and more manageable, especially in large projects.

Last updated