You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
Copy file name to clipboardExpand all lines: pages/Compiler Options.md
+16-13Lines changed: 16 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,40 +6,43 @@ Option | Type | Default
6
6
`--allowSyntheticDefaultImports` | `boolean` | `module === "system"` | Allow default imports from modules with no default export. This does not affect code emit, just typechecking.
7
7
`--allowUnreachableCode` | `boolean` | `false` | Do not report errors on unreachable code.
8
8
`--allowUnusedLabels` | `boolean` | `false` | Do not report errors on unused labels.
9
+
`--alwaysStrict` | `boolean` | `false` | Parse in strict mode and emit `"use strict"` for each source file
9
10
`--baseUrl` | `string` | | Base directory to resolve non-relative module names. See [Module Resolution documentation](./Module Resolution.md#base-url) for more details.
10
11
`--charset` | `string` | `"utf8"` | The character set of the input files.
`--emitBOM` | `boolean` | `false` | Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.
16
17
`--emitDecoratorMetadata`<sup>[1]</sup> | `boolean` | `false` | Emit design-type metadata for decorated declarations in source. See [issue #2577](https://github.com/Microsoft/TypeScript/issues/2577) for details.
17
-
`--experimentalDecorators`<sup>[1]</sup> | `boolean` | `false` | Enables experimental support for ES7 decorators.
18
+
`--experimentalDecorators`<sup>[1]</sup> | `boolean` | `false` | Enables experimental support for ES decorators.
18
19
`--forceConsistentCasingInFileNames` | `boolean` | `false` | Disallow inconsistently-cased references to the same file.
`--inlineSourceMap` | `boolean` | `false` | Emit a single file with source maps instead of having a separate file.
21
23
`--inlineSources` | `boolean` | `false` | Emit the source alongside the sourcemaps within a single file; requires `--inlineSourceMap` or `--sourceMap` to be set.
22
24
`--init` | | | Initializes a TypeScript project and creates a `tsconfig.json` file.
`--jsx` | `string` | `"Preserve"` | Support JSX in '.tsx' files: `'React'` or `'Preserve'`. See [JSX](./JSX.md).
25
-
`--lib` | `string[]`| | List of library files to be included in the compilation.<br/>Possible values are: <br/>► `es5` <br/>► `es6` <br/>► `es2015` <br/>► `es7` <br/>► `es2016` <br/>► `es2017` <br/>► `dom` <br/>► `webworker` <br/>► `scripthost` <br/>► `es2015.core` <br/>► `es2015.collection` <br/>► `es2015.generator` <br/>► `es2015.iterable` <br/>► `es2015.promise` <br/>► `es2015.proxy` <br/>► `es2015.reflect` <br/>► `es2015.symbol` <br/>► `es2015.symbol.wellknown` <br/>► `es2016.array.include` <br/>► `es2017.object` <br/>► `es2017.sharedmemory` <br/><br/> Note: If `--lib` is not specified a default library is injected. The default library injected is: <br/> ► For `--target ES5`: `dom,es5,scripthost`<br/> ► For `--target ES6`: `dom,es6,dom.iterable,scripthost`
26
+
`--jsx` | `string` | `"Preserve"` | Support JSX in `.tsx` files: `"React"` or `"Preserve"`. See [JSX](./JSX.md).
27
+
`--jsxFactory` | `string` | `"React.createElement"` | Specify the JSX factory function to use when targeting react JSX emit, e.g. `React.createElement` or `h`.
28
+
`--lib` | `string[]`| | List of library files to be included in the compilation.<br/>Possible values are: <br/>► `ES5` <br/>► `ES6` <br/>► `ES2015` <br/>► `ES7` <br/>► `ES2016` <br/>► `ES2017` <br/>► `DOM` <br/>► `DOM.Iterable` <br/>► `WebWorker` <br/>► `ScriptHost` <br/>► `ES2015.Core` <br/>► `ES2015.Collection` <br/>► `ES2015.Generator` <br/>► `ES2015.Iterable` <br/>► `ES2015.Promise` <br/>► `ES2015.Proxy` <br/>► `ES2015.Reflect` <br/>► `ES2015.Symbol` <br/>► `ES2015.Symbol.WellKnown` <br/>► `ES2016.Array.Include` <br/>► `ES2017.object` <br/>► `ES2017.SharedMemory` <br/><br/> Note: If `--lib` is not specified a default library is injected. The default library injected is: <br/> ► For `--target ES5`: `DOM,ES5,ScriptHost`<br/> ► For `--target ES6`: `DOM,ES6,DOM.Iterable,ScriptHost`
26
29
`--listEmittedFiles` | `boolean` | `false` | Print names of generated files part of the compilation.
27
30
`--listFiles` | `boolean` | `false` | Print names of files part of the compilation.
28
31
`--locale` | `string` | *(platform specific)* | The locale to use to show error messages, e.g. en-us.
29
32
`--mapRoot` | `string` | | Specifies the location where debugger should locate map files instead of generated locations. Use this flag if the .map files will be located at run-time in a different location than the .js files. The location specified will be embedded in the sourceMap to direct the debugger where the map files will be located.
30
33
`--maxNodeModuleJsDepth` | `number` | `0` | The maximum dependency depth to search under node_modules and load JavaScript files. Only applicable with `--allowJs`.
31
-
`--module`<br/>`-m` | `string` | `target === 'ES6' ? 'ES6' : 'commonjs'` | Specify module code generation: `'none'`, `'commonjs'`, `'amd'`, `'system'`, `'umd'`, `'es6'`, or `'es2015'`.<br/>► Only `'amd'` and `'system'` can be used in conjunction with `--outFile`.<br/>► `'es6'` and `'es2015'` values may not be used when targeting ES5 or lower.
32
-
`--moduleResolution` | `string` | `module === 'amd' | 'system' | 'ES6' ? 'classic' : 'node'` | Determine how modules get resolved. Either `'node'` for Node.js/io.js style resolution, or `'classic'`. See [Module Resolution documentation](./Module Resolution.md) for more details.
33
-
`--newLine` | `string` | *(platform specific)* | Use the specified end of line sequence to be used when emitting files: `'crlf'` (windows) or `'lf'` (unix)."
34
+
`--module`<br/>`-m` | `string` | `target === "ES6" ? "ES6" : "CommonJS"` | Specify module code generation: `"None"`, `"CommonJS"`, `"AMD"`, `"System"`, `"UMD"`, `"ES6"`, or `"ES2015"`.<br/>► Only `"AMD"` and `"System"` can be used in conjunction with `--outFile`.<br/>► `"ES6"` and `"ES2015"` values may not be used when targeting `"ES5"` or lower.
35
+
`--moduleResolution` | `string` | `module === "AMD" | "System" | "ES6" ? "Classic" : "Node"` | Determine how modules get resolved. Either `"Node"` for Node.js/io.js style resolution, or `"Classic"`. See [Module Resolution documentation](./Module Resolution.md) for more details.
36
+
`--newLine` | `string` | *(platform specific)* | Use the specified end of line sequence to be used when emitting files: `"crlf"` (windows) or `"lf"` (unix)."
34
37
`--noEmit` | `boolean` | `false` | Do not emit outputs.
35
38
`--noEmitHelpers` | `boolean` | `false` | Do not generate custom helper functions like `__extends` in compiled output.
36
39
`--noEmitOnError` | `boolean` | `false` | Do not emit outputs if any errors were reported.
37
40
`--noFallthroughCasesInSwitch` | `boolean` | `false` | Report errors for fallthrough cases in switch statement.
38
-
`--noImplicitAny` | `boolean` | `false` | Raise error on expressions and declarations with an implied 'any' type.
41
+
`--noImplicitAny` | `boolean` | `false` | Raise error on expressions and declarations with an implied `any` type.
39
42
`--noImplicitReturns` | `boolean` | `false` | Report error when not all code paths in function return a value.
40
-
`--noImplicitThis` | `boolean` | `false` | Raise error on `this` expressions with an implied 'any' type.
43
+
`--noImplicitThis` | `boolean` | `false` | Raise error on `this` expressions with an implied `any` type.
41
44
`--noImplicitUseStrict` | `boolean` | `false` | Do not emit `"use strict"` directives in module output.
42
-
`--noLib` | `boolean` | `false` | Do not include the default library file (lib.d.ts).
45
+
`--noLib` | `boolean` | `false` | Do not include the default library file (`lib.d.ts`).
43
46
`--noResolve` | `boolean` | `false` | Do not add triple-slash references or module import targets to the list of compiled files.
`--preserveConstEnums` | `boolean` | `false` | Do not erase const enum declarations in generated code. See [const enums documentation](https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#94-constant-enum-declarations) for more details.
51
54
`--pretty`<sup>[1]</sup> | `boolean` | `false` | Stylize errors and messages using color and context.
52
55
`--project`<br/>`-p` | `string` | | Compile a project given a valid configuration file.<br/>The argument can be an file path to a valid JSON configuration file, or a directory path to a directory containing a `tsconfig.json` file.<br/>See [tsconfig.json](./tsconfig.json.md) documentation for more details.
53
-
`--reactNamespace` | `string` | `"React"` | Specifies the object invoked for `createElement` and `__spread` when targeting 'react' JSX emit.
56
+
`--reactNamespace` | `string` | `"React"` | Specifies the object invoked for `createElement` and `__spread` when targeting `"react"` JSX emit.
54
57
`--removeComments` | `boolean` | `false` | Remove all comments except copy-right header comments beginning with `/*!`
55
58
`--rootDir` | `string` | *(common root directory is computed from the list of input files)* | Specifies the root directory of input files. Only use to control the output directory structure with `--outDir`.
56
59
`rootDirs`<sup>[2]</sup> | `string[]`| | List of <i>root</i> folders whose combined content represent the structure of the project at runtime. See [Module Resolution documentation](./Module Resolution.md#virtual-directories-with-rootdirs) for more details.
57
60
`--skipDefaultLibCheck` | `boolean` | `false` | Skip type checking of [default library declaration files](./Triple-Slash Directives.md#-reference-no-default-libtrue).
58
61
`--skipLibCheck` | `boolean` | `false` | Skip type checking of all declaration files (`*.d.ts`).
`--sourceRoot` | `string` | | Specifies the location where debugger should locate TypeScript files instead of source locations. Use this flag if the sources will be located at run-time in a different location than that at design-time. The location specified will be embedded in the sourceMap to direct the debugger where the source files will be located.
61
64
`--strictNullChecks` | `boolean` | `false` | In strict null checking mode, the `null` and `undefined` values are not in the domain of every type and are only assignable to themselves and `any` (the one exception being that `undefined` is also assignable to `void`).
62
65
`--stripInternal`<sup>[1]</sup> | `boolean` | `false` | Do not emit declarations for code that has an `/** @internal */` JSDoc annotation.
`--suppressImplicitAnyIndexErrors` | `boolean` | `false` | Suppress `--noImplicitAny` errors for indexing objects lacking index signatures. See [issue #1232](https://github.com/Microsoft/TypeScript/issues/1232#issuecomment-64510362) for more details.
`--types` | `string[]`| | List of names of type definitions to include. See [@types, --typeRoots and --types](./tsconfig.json.md#types-typeroots-and-types) for more details.
68
71
`--typeRoots` | `string[]`| | List of folders to include type definitions from. See [@types, --typeRoots and --types](./tsconfig.json.md#types-typeroots-and-types) for more details.
Copy file name to clipboardExpand all lines: pages/tsconfig.json.md
+51-1Lines changed: 51 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,7 +86,7 @@ Files in the directory specified using the `"outDir"` compiler option are always
86
86
87
87
Files included using `"include"` can be filtered using the `"exclude"` property.
88
88
However, files included explicitly using the `"files"` property are always included regardless of `"exclude"`.
89
-
The `"exclude"` property defaults to excluding the `node_modules`, `bower_components`, and `jspm_packages` directories when not specified.
89
+
The `"exclude"` property defaults to excluding the `node_modules`, `bower_components`, `jspm_packages`and `<outDir>` directories when not specified.
90
90
91
91
Any files that are referenced by files included via the `"files"` or `"include"` properties are also included.
92
92
Similarly, if a file `B.ts` is referenced by another file `A.ts`, then `B.ts` cannot be excluded unless the referencing file `A.ts` is also specified in the `"exclude"` list.
@@ -133,6 +133,56 @@ Specify `"types": []` to disable automatic inclusion of `@types` packages.
133
133
Keep in mind that automatic inclusion is only important if you're using files with global declarations (as opposed to files declared as modules).
134
134
If you use an `import "foo"` statement, for instance, TypeScript may still look through `node_modules` & `node_modules/@types` folders to find the `foo` package.
135
135
136
+
## Configuration inheritance with `extends`
137
+
138
+
A `tsconfig.json` file can inherit configurations from another file using the `extends` property.
139
+
140
+
The `extends` is a top-level property in `tsconfig.json` (alongside `compilerOptions`, `files`, `include`, and `exclude`).
141
+
`extends`' value is a string containing a path to another configuration file to inherit from.
142
+
143
+
The configuration from the base file are loaded first, then overridden by those in the inheriting config file.
144
+
If a circularity is encountered, we report an error.
145
+
146
+
`files`, `include` and `exclude` from the inheriting config file *overwrite* those from the base config file.
147
+
148
+
All relative paths found in the configuration file will be resolved relative to the configuration file they originated in.
149
+
150
+
For example:
151
+
152
+
`configs/base.json`:
153
+
154
+
```json
155
+
{
156
+
"compilerOptions": {
157
+
"noImplicitAny": true,
158
+
"strictNullChecks": true
159
+
}
160
+
}
161
+
```
162
+
163
+
`tsconfig.json`:
164
+
165
+
```json
166
+
{
167
+
"extends": "./configs/base",
168
+
"files": [
169
+
"main.ts",
170
+
"supplemental.ts"
171
+
]
172
+
}
173
+
```
174
+
175
+
`tsconfig.nostrictnull.json`:
176
+
177
+
```json
178
+
{
179
+
"extends": "./tsconfig",
180
+
"compilerOptions": {
181
+
"strictNullChecks": false
182
+
}
183
+
}
184
+
```
185
+
136
186
## `compileOnSave`
137
187
138
188
Setting a top-level property `compileOnSave` signals to the IDE to generate all files for a given tsconfig.json upon saving.
0 commit comments