|
| 1 | +# TypeScript Configuration Options |
| 2 | + |
| 3 | +| Category | Option | Value | Description | |
| 4 | +|----------|--------|-------|-------------| |
| 5 | +| **Language and Environment** | `target` | `"es2016"` | Set the JavaScript language version for emitted JavaScript and include compatible library declarations. | |
| 6 | +| **Modules** | `module` | `"commonjs"` | Specify what module code is generated. | |
| 7 | +| **Interop Constraints** | `esModuleInterop` | `true` | Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. | |
| 8 | +| **Interop Constraints** | `forceConsistentCasingInFileNames` | `true` | Ensure that casing is correct in imports. | |
| 9 | +| **Type Checking** | `strict` | `true` | Enable all strict type-checking options. | |
| 10 | +| **Completeness** | `skipLibCheck` | `true` | Skip type checking all .d.ts files. | |
| 11 | + |
| 12 | +## Commented Out Options |
| 13 | + |
| 14 | +### Projects |
| 15 | +| Option | Description | |
| 16 | +|--------|-------------| |
| 17 | +| `incremental` | Save .tsbuildinfo files to allow for incremental compilation of projects. | |
| 18 | +| `composite` | Enable constraints that allow a TypeScript project to be used with project references. | |
| 19 | +| `tsBuildInfoFile` | Specify the path to .tsbuildinfo incremental compilation file. | |
| 20 | +| `disableSourceOfProjectReferenceRedirect` | Disable preferring source files instead of declaration files when referencing composite projects. | |
| 21 | +| `disableSolutionSearching` | Opt a project out of multi-project reference checking when editing. | |
| 22 | +| `disableReferencedProjectLoad` | Reduce the number of projects loaded automatically by TypeScript. | |
| 23 | + |
| 24 | +### Language and Environment |
| 25 | +| Option | Description | |
| 26 | +|--------|-------------| |
| 27 | +| `lib` | Specify a set of bundled library declaration files that describe the target runtime environment. | |
| 28 | +| `jsx` | Specify what JSX code is generated. | |
| 29 | +| `libReplacement` | Enable lib replacement. | |
| 30 | +| `experimentalDecorators` | Enable experimental support for legacy experimental decorators. | |
| 31 | +| `emitDecoratorMetadata` | Emit design-type metadata for decorated declarations in source files. | |
| 32 | +| `jsxFactory` | Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. | |
| 33 | +| `jsxFragmentFactory` | Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. | |
| 34 | +| `jsxImportSource` | Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. | |
| 35 | +| `reactNamespace` | Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. | |
| 36 | +| `noLib` | Disable including any library files, including the default lib.d.ts. | |
| 37 | +| `useDefineForClassFields` | Emit ECMAScript-standard-compliant class fields. | |
| 38 | +| `moduleDetection` | Control what method is used to detect module-format JS files. | |
| 39 | + |
| 40 | +### Modules |
| 41 | +| Option | Description | |
| 42 | +|--------|-------------| |
| 43 | +| `rootDir` | Specify the root folder within your source files. | |
| 44 | +| `moduleResolution` | Specify how TypeScript looks up a file from a given module specifier. | |
| 45 | +| `baseUrl` | Specify the base directory to resolve non-relative module names. | |
| 46 | +| `paths` | Specify a set of entries that re-map imports to additional lookup locations. | |
| 47 | +| `rootDirs` | Allow multiple folders to be treated as one when resolving modules. | |
| 48 | +| `typeRoots` | Specify multiple folders that act like './node_modules/@types'. | |
| 49 | +| `types` | Specify type package names to be included without being referenced in a source file. | |
| 50 | +| `allowUmdGlobalAccess` | Allow accessing UMD globals from modules. | |
| 51 | +| `moduleSuffixes` | List of file name suffixes to search when resolving a module. | |
| 52 | +| `allowImportingTsExtensions` | Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. | |
| 53 | +| `rewriteRelativeImportExtensions` | Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. | |
| 54 | +| `resolvePackageJsonExports` | Use the package.json 'exports' field when resolving package imports. | |
| 55 | +| `resolvePackageJsonImports` | Use the package.json 'imports' field when resolving imports. | |
| 56 | +| `customConditions` | Conditions to set in addition to the resolver-specific defaults when resolving imports. | |
| 57 | +| `noUncheckedSideEffectImports` | Check side effect imports. | |
| 58 | +| `resolveJsonModule` | Enable importing .json files. | |
| 59 | +| `allowArbitraryExtensions` | Enable importing files with any extension, provided a declaration file is present. | |
| 60 | +| `noResolve` | Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. | |
| 61 | + |
| 62 | +### JavaScript Support |
| 63 | +| Option | Description | |
| 64 | +|--------|-------------| |
| 65 | +| `allowJs` | Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. | |
| 66 | +| `checkJs` | Enable error reporting in type-checked JavaScript files. | |
| 67 | +| `maxNodeModuleJsDepth` | Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. | |
| 68 | + |
| 69 | +### Emit |
| 70 | +| Option | Description | |
| 71 | +|--------|-------------| |
| 72 | +| `declaration` | Generate .d.ts files from TypeScript and JavaScript files in your project. | |
| 73 | +| `declarationMap` | Create sourcemaps for d.ts files. | |
| 74 | +| `emitDeclarationOnly` | Only output d.ts files and not JavaScript files. | |
| 75 | +| `sourceMap` | Create source map files for emitted JavaScript files. | |
| 76 | +| `inlineSourceMap` | Include sourcemap files inside the emitted JavaScript. | |
| 77 | +| `noEmit` | Disable emitting files from a compilation. | |
| 78 | +| `outFile` | Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. | |
| 79 | +| `outDir` | Specify an output folder for all emitted files. | |
| 80 | +| `removeComments` | Disable emitting comments. | |
| 81 | +| `importHelpers` | Allow importing helper functions from tslib once per project, instead of including them per-file. | |
| 82 | +| `downlevelIteration` | Emit more compliant, but verbose and less performant JavaScript for iteration. | |
| 83 | +| `sourceRoot` | Specify the root path for debuggers to find the reference source code. | |
| 84 | +| `mapRoot` | Specify the location where debugger should locate map files instead of generated locations. | |
| 85 | +| `inlineSources` | Include source code in the sourcemaps inside the emitted JavaScript. | |
| 86 | +| `emitBOM` | Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. | |
| 87 | +| `newLine` | Set the newline character for emitting files. | |
| 88 | +| `stripInternal` | Disable emitting declarations that have '@internal' in their JSDoc comments. | |
| 89 | +| `noEmitHelpers` | Disable generating custom helper functions like '__extends' in compiled output. | |
| 90 | +| `noEmitOnError` | Disable emitting files if any type checking errors are reported. | |
| 91 | +| `preserveConstEnums` | Disable erasing 'const enum' declarations in generated code. | |
| 92 | +| `declarationDir` | Specify the output directory for generated declaration files. | |
| 93 | + |
| 94 | +### Interop Constraints |
| 95 | +| Option | Description | |
| 96 | +|--------|-------------| |
| 97 | +| `isolatedModules` | Ensure that each file can be safely transpiled without relying on other imports. | |
| 98 | +| `verbatimModuleSyntax` | Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. | |
| 99 | +| `isolatedDeclarations` | Require sufficient annotation on exports so other tools can trivially generate declaration files. | |
| 100 | +| `erasableSyntaxOnly` | Do not allow runtime constructs that are not part of ECMAScript. | |
| 101 | +| `allowSyntheticDefaultImports` | Allow 'import x from y' when a module doesn't have a default export. | |
| 102 | +| `preserveSymlinks` | Disable resolving symlinks to their realpath. This correlates to the same flag in node. | |
| 103 | + |
| 104 | +### Type Checking |
| 105 | +| Option | Description | |
| 106 | +|--------|-------------| |
| 107 | +| `noImplicitAny` | Enable error reporting for expressions and declarations with an implied 'any' type. | |
| 108 | +| `strictNullChecks` | When type checking, take into account 'null' and 'undefined'. | |
| 109 | +| `strictFunctionTypes` | When assigning functions, check to ensure parameters and the return values are subtype-compatible. | |
| 110 | +| `strictBindCallApply` | Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. | |
| 111 | +| `strictPropertyInitialization` | Check for class properties that are declared but not set in the constructor. | |
| 112 | +| `strictBuiltinIteratorReturn` | Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. | |
| 113 | +| `noImplicitThis` | Enable error reporting when 'this' is given the type 'any'. | |
| 114 | +| `useUnknownInCatchVariables` | Default catch clause variables as 'unknown' instead of 'any'. | |
| 115 | +| `alwaysStrict` | Ensure 'use strict' is always emitted. | |
| 116 | +| `noUnusedLocals` | Enable error reporting when local variables aren't read. | |
| 117 | +| `noUnusedParameters` | Raise an error when a function parameter isn't read. | |
| 118 | +| `exactOptionalPropertyTypes` | Interpret optional property types as written, rather than adding 'undefined'. | |
| 119 | +| `noImplicitReturns` | Enable error reporting for codepaths that do not explicitly return in a function. | |
| 120 | +| `noFallthroughCasesInSwitch` | Enable error reporting for fallthrough cases in switch statements. | |
| 121 | +| `noUncheckedIndexedAccess` | Add 'undefined' to a type when accessed using an index. | |
| 122 | +| `noImplicitOverride` | Ensure overriding members in derived classes are marked with an override modifier. | |
| 123 | +| `noPropertyAccessFromIndexSignature` | Enforces using indexed accessors for keys declared using an indexed type. | |
| 124 | +| `allowUnusedLabels` | Disable error reporting for unused labels. | |
| 125 | +| `allowUnreachableCode` | Disable error reporting for unreachable code. | |
| 126 | + |
| 127 | +### Completeness |
| 128 | +| Option | Description | |
| 129 | +|--------|-------------| |
| 130 | +| `skipDefaultLibCheck` | Skip type checking .d.ts files that are included with TypeScript. | |
0 commit comments