TypeScriptCompilerOptions

interface TypeScriptCompilerOptions {
    allowArbitraryExtensions?: boolean;
    allowImportingTsExtensions?: boolean;
    allowJs?: boolean;
    allowSyntheticDefaultImports?: boolean;
    allowUnreachableCode?: boolean;
    allowUnusedLabels?: boolean;
    alwaysStrict?: boolean;
    baseUrl?: string;
    checkJs?: boolean;
    customConditions?: string[];
    declaration?: boolean;
    declarationDir?: string;
    declarationMap?: boolean;
    downlevelIteration?: boolean;
    emitDeclarationOnly?: boolean;
    emitDecoratorMetadata?: boolean;
    esModuleInterop?: boolean;
    exactOptionalPropertyTypes?: boolean;
    experimentalDecorators?: boolean;
    forceConsistentCasingInFileNames?: boolean;
    importsNotUsedAsValues?: TypeScriptImportsNotUsedAsValues;
    incremental?: boolean;
    inlineSourceMap?: boolean;
    inlineSources?: boolean;
    isolatedModules?: boolean;
    jsx?: TypeScriptJsxMode;
    jsxImportSource?: string;
    lib?: string[];
    module?: string;
    moduleDetection?: TypeScriptModuleDetection;
    moduleResolution?: TypeScriptModuleResolution;
    noEmit?: boolean;
    noEmitOnError?: boolean;
    noFallthroughCasesInSwitch?: boolean;
    noImplicitAny?: boolean;
    noImplicitOverride?: boolean;
    noImplicitReturns?: boolean;
    noImplicitThis?: boolean;
    noPropertyAccessFromIndexSignature?: boolean;
    noUncheckedIndexedAccess?: boolean;
    noUnusedLocals?: boolean;
    noUnusedParameters?: boolean;
    outDir?: string;
    paths?: Record<string, string[]>;
    resolveJsonModule?: boolean;
    resolvePackageJsonExports?: boolean;
    resolvePackageJsonImports?: boolean;
    rootDir?: string;
    skipLibCheck?: boolean;
    sourceMap?: boolean;
    sourceRoot?: string;
    strict?: boolean;
    strictNullChecks?: boolean;
    strictPropertyInitialization?: boolean;
    stripInternal?: boolean;
    target?: string;
    tsBuildInfoFile?: string;
    typeRoots?: string[];
    types?: string[];
    useUnknownInCatchVariables?: boolean;
    verbatimModuleSyntax?: boolean;
}

Properties

allowArbitraryExtensions?: boolean

Suppress arbitrary extension import errors with the assumption that a bundler will be handling it.

undefined

experimental

allowImportingTsExtensions?: boolean

Allows TypeScript files to import each other with TypeScript-specific extensions (.ts, .mts, .tsx). Requires noEmit or emitDeclarationOnly.

undefined

experimental

allowJs?: boolean

Allow JavaScript files to be compiled.

false

experimental

allowSyntheticDefaultImports?: boolean

Allow default imports from modules with no default export. This does not affect code emit, just typechecking.

experimental

allowUnreachableCode?: boolean

Allow Unreachable Code. When:

  • undefined (default) provide suggestions as warnings to editors
  • true unreachable code is ignored
  • false raises compiler errors about unreachable code

These warnings are only about code which is provably unreachable due to the use of JavaScript syntax.

experimental

allowUnusedLabels?: boolean

Allow Unused Labels. When:

  • undefined (default) provide suggestions as warnings to editors
  • true unused labels are ignored
  • false raises compiler errors about unused labels

Labels are very rare in JavaScript and typically indicate an attempt to write an object literal:

function verifyAge(age: number) {
// Forgot 'return' statement
if (age > 18) {
verified: true;
// ^^^^^^^^ Unused label.
}
}

experimental

alwaysStrict?: boolean

Ensures that your files are parsed in the ECMAScript strict mode, and emit “use strict” for each source file.

true

experimental

baseUrl?: string

Lets you set a base directory to resolve non-absolute module names. You can define a root folder where you can do absolute file resolution.

experimental

checkJs?: boolean

Check JS. Works in tandem with allowJs. When checkJs is enabled then errors are reported in JavaScript files. This is the equivalent of including //

experimental @ts-check at the top of all JavaScript files which are included in your project.

customConditions?: string[]

List of additional conditions that should succeed when TypeScript resolves from an exports or imports field of a package.json.

undefined

experimental

declaration?: boolean

To be specified along with the above.

experimental

declarationDir?: string

Offers a way to configure the root directory for where declaration files are emitted.

experimental

declarationMap?: boolean

Generates a source map for .d.ts files which map back to the original .ts source file. This will allow editors such as VS Code to go to the original .ts file when using features like Go to Definition.

experimental

downlevelIteration?: boolean

Downleveling is TypeScript’s term for transpiling to an older version of JavaScript. This flag is to enable support for a more accurate implementation of how modern JavaScript iterates through new concepts in older JavaScript runtimes.

ECMAScript 6 added several new iteration primitives: the for / of loop (for (el of arr)), Array spread ([a, ...b]), argument spread (fn(...args)), and Symbol.iterator. downlevelIteration allows for these iteration primitives to be used more accurately in ES5 environments if a Symbol.iterator implementation is present.

experimental

emitDeclarationOnly?: boolean

Only emit .d.ts files; do not emit .js files.

false

experimental

emitDecoratorMetadata?: boolean

Enables experimental support for decorators, which is in stage 2 of the TC39 standardization process. Decorators are a language feature which hasn’t yet been fully ratified into the JavaScript specification. This means that the implementation version in TypeScript may differ from the implementation in JavaScript when it it decided by TC39. You can find out more about decorator support in TypeScript in the handbook.

undefined

experimental

esModuleInterop?: boolean

Emit __importStar and __importDefault helpers for runtime babel ecosystem compatibility and enable --allowSyntheticDefaultImports for typesystem compatibility.

false

experimental

exactOptionalPropertyTypes?: boolean

Specifies that optional property types should be interpreted exactly as written, meaning that | undefined is not added to the type Available with TypeScript 4.4 and newer.

false

experimental

experimentalDecorators?: boolean

Enables experimental support for decorators, which is in stage 2 of the TC39 standardization process.

true

experimental

forceConsistentCasingInFileNames?: boolean

Disallow inconsistently-cased references to the same file.

false

experimental

importsNotUsedAsValues?: TypeScriptImportsNotUsedAsValues

This flag works because you can use import type to explicitly create an import statement which should never be emitted into JavaScript.

"remove"

experimental

For TypeScript 5.0+ use verbatimModuleSyntax instead. Posed for deprecation upon TypeScript 5.5.

incremental?: boolean

Tells TypeScript to save information about the project graph from the last compilation to files stored on disk. This creates a series of .tsbuildinfo files in the same folder as your compilation output. They are not used by your JavaScript at runtime and can be safely deleted. You can read more about the flag in the 3.4 release notes.

experimental

inlineSourceMap?: boolean

When set, instead of writing out a .js.map file to provide source maps, TypeScript will embed the source map content in the .js files.

true

experimental

inlineSources?: boolean

When set, TypeScript will include the original content of the .ts file as an embedded string in the source map. This is often useful in the same cases as inlineSourceMap.

true

experimental

isolatedModules?: boolean

Perform additional checks to ensure that separate compilation (such as with transpileModule or.

false

experimental

/plugin-transform-typescript) would be safe.

jsx?: TypeScriptJsxMode

Support JSX in .tsx files: "react", "preserve", "react-native" etc.

undefined

experimental

jsxImportSource?: string

Declares the module specifier to be used for importing the jsx and jsxs factory functions when using jsx.

undefined

experimental

lib?: string[]

Reference for type definitions / libraries to use (eg. ES2016, ES5, ES2018).

[ "es2018" ]

experimental

module?: string
"CommonJS"

experimental

moduleDetection?: TypeScriptModuleDetection

This setting controls how TypeScript determines whether a file is a script or a module.

"auto"

experimental

moduleResolution?: TypeScriptModuleResolution

Determine how modules get resolved. Either "Node" for Node.js/io.js style resolution, or "Classic".

"node"

experimental

noEmit?: boolean

Do not emit outputs.

false

experimental

noEmitOnError?: boolean

Do not emit compiler output files like JavaScript source code, source-maps or declarations if any errors were reported.

true

experimental

noFallthroughCasesInSwitch?: boolean

Report errors for fallthrough cases in switch statements. Ensures that any non-empty case inside a switch statement includes either break or return. This means you won’t accidentally ship a case fallthrough bug.

true

experimental

noImplicitAny?: boolean

In some cases where no type annotations are present, TypeScript will fall back to a type of any for a variable when it cannot infer the type.

true

experimental

noImplicitOverride?: boolean

Using noImplicitOverride, you can ensure that sub-classes never go out of sync as they are required to explicitly declare that they are overriding a member using the override keyword. This also improves readability of the programmer's intent.

Available with TypeScript 4.3 and newer.

false

experimental

noImplicitReturns?: boolean

When enabled, TypeScript will check all code paths in a function to ensure they return a value.

true

experimental

noImplicitThis?: boolean

Raise error on ‘this’ expressions with an implied ‘any’ type.

true

experimental

noPropertyAccessFromIndexSignature?: boolean

Raise error on use of the dot syntax to access fields which are not defined.

true

experimental

noUncheckedIndexedAccess?: boolean

Raise error when accessing indexes on objects with unknown keys defined in index signatures.

true

experimental

noUnusedLocals?: boolean

Report errors on unused local variables.

true

experimental

noUnusedParameters?: boolean

Report errors on unused parameters in functions.

true

experimental

outDir?: string

Output directory for the compiled files.

experimental

paths?: Record<string, string[]>

A series of entries which re-map imports to lookup locations relative to the baseUrl, there is a larger coverage of paths in the handbook. paths lets you declare how TypeScript should resolve an import in your require/imports.

experimental

resolveJsonModule?: boolean

Allows importing modules with a ‘.json’ extension, which is a common practice in node projects. This includes generating a type for the import based on the static JSON shape.

true

experimental

resolvePackageJsonExports?: boolean

Forces TypeScript to consult the exports field of package.json files if it ever reads from a package in node_modules.

true

experimental

resolvePackageJsonImports?: boolean

Forces TypeScript to consult the imports field of package.json when performing a lookup that begins with # from a file that has a package.json as an ancestor.

undefined

experimental

rootDir?: string

Specifies the root directory of input files. Only use to control the output directory structure with outDir.

experimental

skipLibCheck?: boolean

Skip type checking of all declaration files (*.d.ts).

false

experimental

sourceMap?: boolean

Enables the generation of sourcemap files.

undefined

experimental

sourceRoot?: string

Specify the location where a debugger should locate TypeScript files instead of relative source locations.

undefined

experimental

strict?: boolean

The strict flag enables a wide range of type checking behavior that results in stronger guarantees of program correctness. Turning this on is equivalent to enabling all of the strict mode family options, which are outlined below. You can then turn off individual strict mode family checks as needed.

true

experimental

strictNullChecks?: boolean

When strictNullChecks is false, null and undefined are effectively ignored by the language. This can lead to unexpected errors at runtime. When strictNullChecks is true, null and undefined have their own distinct types and you’ll get a type error if you try to use them where a concrete value is expected.

true

experimental

strictPropertyInitialization?: boolean

When set to true, TypeScript will raise an error when a class property was declared but not set in the constructor.

true

experimental

stripInternal?: boolean

Do not emit declarations for code that has an @internal annotation in it’s JSDoc comment.

true

experimental

target?: string

Modern browsers support all ES6 features, so ES6 is a good choice. You might choose to set a lower target if your code is deployed to older environments, or a higher target if your code is guaranteed to run in newer environments.

"ES2018"

experimental

tsBuildInfoFile?: string

This setting lets you specify a file for storing incremental compilation information as a part of composite projects which enables faster building of larger TypeScript codebases. You can read more about composite projects in the handbook.

experimental

typeRoots?: string[]

If typeRoots is specified, only packages under typeRoots will be included.

experimental

types?: string[]

Types to include in compilation.

useUnknownInCatchVariables?: boolean

Change the type of the variable in a catch clause from any to unknown Available with TypeScript 4.4 and newer.

true

experimental

verbatimModuleSyntax?: boolean

Simplifies TypeScript's handling of import/export type modifiers.

undefined

experimental