ai-hero-cli 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/tsconfig/allowArbitraryExtensions.md +38 -0
- package/docs/tsconfig/allowImportingTsExtensions.md +9 -0
- package/docs/tsconfig/allowJs.md +41 -0
- package/docs/tsconfig/allowSyntheticDefaultImports.md +56 -0
- package/docs/tsconfig/allowUmdGlobalAccess.md +8 -0
- package/docs/tsconfig/allowUnreachableCode.md +40 -0
- package/docs/tsconfig/allowUnusedLabels.md +23 -0
- package/docs/tsconfig/alwaysStrict.md +8 -0
- package/docs/tsconfig/assumeChangesOnlyAffectDirectDependencies.md +8 -0
- package/docs/tsconfig/baseUrl.md +26 -0
- package/docs/tsconfig/charset.md +7 -0
- package/docs/tsconfig/checkJs.md +40 -0
- package/docs/tsconfig/clean.md +6 -0
- package/docs/tsconfig/composite.md +17 -0
- package/docs/tsconfig/customConditions.md +41 -0
- package/docs/tsconfig/declaration.md +32 -0
- package/docs/tsconfig/declarationDir.md +36 -0
- package/docs/tsconfig/declarationMap.md +9 -0
- package/docs/tsconfig/diagnostics.md +8 -0
- package/docs/tsconfig/disableFilenameBasedTypeAcquisition.md +16 -0
- package/docs/tsconfig/disableReferencedProjectLoad.md +8 -0
- package/docs/tsconfig/disableSizeLimit.md +6 -0
- package/docs/tsconfig/disableSolutionSearching.md +8 -0
- package/docs/tsconfig/disableSourceOfProjectReferenceRedirect.md +7 -0
- package/docs/tsconfig/downlevelIteration.md +100 -0
- package/docs/tsconfig/emitBOM.md +8 -0
- package/docs/tsconfig/emitDeclarationOnly.md +11 -0
- package/docs/tsconfig/emitDecoratorMetadata.md +81 -0
- package/docs/tsconfig/enable.md +14 -0
- package/docs/tsconfig/erasableSyntaxOnly.md +65 -0
- package/docs/tsconfig/esModuleInterop.md +74 -0
- package/docs/tsconfig/exactOptionalPropertyTypes.md +37 -0
- package/docs/tsconfig/exclude.md +11 -0
- package/docs/tsconfig/excludeDirectories.md +14 -0
- package/docs/tsconfig/excludeFiles.md +14 -0
- package/docs/tsconfig/experimentalDecorators.md +11 -0
- package/docs/tsconfig/explainFiles.md +54 -0
- package/docs/tsconfig/extendedDiagnostics.md +9 -0
- package/docs/tsconfig/extends.md +49 -0
- package/docs/tsconfig/fallbackPolling.md +11 -0
- package/docs/tsconfig/files.md +26 -0
- package/docs/tsconfig/force.md +6 -0
- package/docs/tsconfig/forceConsistentCasingInFileNames.md +10 -0
- package/docs/tsconfig/generateCpuProfile.md +15 -0
- package/docs/tsconfig/generateTrace.md +6 -0
- package/docs/tsconfig/importHelpers.md +46 -0
- package/docs/tsconfig/importsNotUsedAsValues.md +16 -0
- package/docs/tsconfig/include.md +66 -0
- package/docs/tsconfig/incremental.md +10 -0
- package/docs/tsconfig/inlineSourceMap.md +35 -0
- package/docs/tsconfig/inlineSources.md +36 -0
- package/docs/tsconfig/isolatedDeclarations.md +8 -0
- package/docs/tsconfig/isolatedModules.md +77 -0
- package/docs/tsconfig/jsx.md +111 -0
- package/docs/tsconfig/jsxFactory.md +43 -0
- package/docs/tsconfig/jsxFragmentFactory.md +69 -0
- package/docs/tsconfig/jsxImportSource.md +95 -0
- package/docs/tsconfig/keyofStringsOnly.md +8 -0
- package/docs/tsconfig/lib.md +75 -0
- package/docs/tsconfig/libReplacement.md +22 -0
- package/docs/tsconfig/listEmittedFiles.md +42 -0
- package/docs/tsconfig/listFiles.md +40 -0
- package/docs/tsconfig/locale.md +26 -0
- package/docs/tsconfig/mapRoot.md +18 -0
- package/docs/tsconfig/maxNodeModuleJsDepth.md +11 -0
- package/docs/tsconfig/module.md +125 -0
- package/docs/tsconfig/moduleDetection.md +15 -0
- package/docs/tsconfig/moduleResolution.md +13 -0
- package/docs/tsconfig/moduleSuffixes.md +26 -0
- package/docs/tsconfig/newLine.md +6 -0
- package/docs/tsconfig/noCheck.md +6 -0
- package/docs/tsconfig/noEmit.md +10 -0
- package/docs/tsconfig/noEmitHelpers.md +38 -0
- package/docs/tsconfig/noEmitOnError.md +8 -0
- package/docs/tsconfig/noErrorTruncation.md +45 -0
- package/docs/tsconfig/noFallthroughCasesInSwitch.md +22 -0
- package/docs/tsconfig/noImplicitAny.md +26 -0
- package/docs/tsconfig/noImplicitOverride.md +66 -0
- package/docs/tsconfig/noImplicitReturns.md +17 -0
- package/docs/tsconfig/noImplicitThis.md +28 -0
- package/docs/tsconfig/noImplicitUseStrict.md +7 -0
- package/docs/tsconfig/noLib.md +9 -0
- package/docs/tsconfig/noPropertyAccessFromIndexSignature.md +57 -0
- package/docs/tsconfig/noResolve.md +9 -0
- package/docs/tsconfig/noStrictGenericChecks.md +20 -0
- package/docs/tsconfig/noUncheckedIndexedAccess.md +53 -0
- package/docs/tsconfig/noUncheckedSideEffectImports.md +52 -0
- package/docs/tsconfig/noUnusedLocals.md +15 -0
- package/docs/tsconfig/noUnusedParameters.md +15 -0
- package/docs/tsconfig/out.md +9 -0
- package/docs/tsconfig/outDir.md +39 -0
- package/docs/tsconfig/outFile.md +11 -0
- package/docs/tsconfig/paths.md +39 -0
- package/docs/tsconfig/plugins.md +17 -0
- package/docs/tsconfig/preserveConstEnums.md +58 -0
- package/docs/tsconfig/preserveSymlinks.md +10 -0
- package/docs/tsconfig/preserveValueImports.md +18 -0
- package/docs/tsconfig/preserveWatchOutput.md +6 -0
- package/docs/tsconfig/pretty.md +7 -0
- package/docs/tsconfig/reactNamespace.md +6 -0
- package/docs/tsconfig/references.md +9 -0
- package/docs/tsconfig/removeComments.md +33 -0
- package/docs/tsconfig/resolveJsonModule.md +44 -0
- package/docs/tsconfig/resolvePackageJsonExports.md +8 -0
- package/docs/tsconfig/resolvePackageJsonImports.md +8 -0
- package/docs/tsconfig/rewriteRelativeImportExtensions.md +8 -0
- package/docs/tsconfig/rootDir.md +66 -0
- package/docs/tsconfig/rootDirs.md +66 -0
- package/docs/tsconfig/skipDefaultLibCheck.md +6 -0
- package/docs/tsconfig/skipLibCheck.md +19 -0
- package/docs/tsconfig/sourceMap.md +39 -0
- package/docs/tsconfig/sourceRoot.md +18 -0
- package/docs/tsconfig/stopBuildOnErrors.md +6 -0
- package/docs/tsconfig/strict.md +11 -0
- package/docs/tsconfig/strictBindCallApply.md +34 -0
- package/docs/tsconfig/strictBuiltinIteratorReturn.md +6 -0
- package/docs/tsconfig/strictFunctionTypes.md +55 -0
- package/docs/tsconfig/strictNullChecks.md +58 -0
- package/docs/tsconfig/strictPropertyInitialization.md +29 -0
- package/docs/tsconfig/stripInternal.md +60 -0
- package/docs/tsconfig/suppressExcessPropertyErrors.md +16 -0
- package/docs/tsconfig/suppressImplicitAnyIndexErrors.md +25 -0
- package/docs/tsconfig/synchronousWatchDirectory.md +14 -0
- package/docs/tsconfig/target.md +18 -0
- package/docs/tsconfig/traceResolution.md +7 -0
- package/docs/tsconfig/tsBuildInfoFile.md +17 -0
- package/docs/tsconfig/typeAcquisition.md +37 -0
- package/docs/tsconfig/typeRoots.md +21 -0
- package/docs/tsconfig/types.md +40 -0
- package/docs/tsconfig/useDefineForClassFields.md +10 -0
- package/docs/tsconfig/useUnknownInCatchVariables.md +21 -0
- package/docs/tsconfig/verbatimModuleSyntax.md +148 -0
- package/docs/tsconfig/verbose.md +6 -0
- package/docs/tsconfig/watchDirectory.md +10 -0
- package/docs/tsconfig/watchFile.md +12 -0
- package/package.json +4 -2
- package/prompts/hows-my-tsconfig-score.md +29 -0
- package/prompts/hows-my-tsconfig.md +75 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Emit Decorator Metadata'
|
|
3
|
+
oneline: 'Emit design-type metadata for decorated declarations in source files.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Enables experimental support for emitting type metadata for decorators which works with the module [`reflect-metadata`](https://www.npmjs.com/package/reflect-metadata).
|
|
7
|
+
|
|
8
|
+
For example, here is the TypeScript
|
|
9
|
+
|
|
10
|
+
```ts twoslash
|
|
11
|
+
// @experimentalDecorators
|
|
12
|
+
function LogMethod(
|
|
13
|
+
target: any,
|
|
14
|
+
propertyKey: string | symbol,
|
|
15
|
+
descriptor: PropertyDescriptor,
|
|
16
|
+
) {
|
|
17
|
+
console.log(target);
|
|
18
|
+
console.log(propertyKey);
|
|
19
|
+
console.log(descriptor);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
class Demo {
|
|
23
|
+
@LogMethod
|
|
24
|
+
public foo(bar: number) {
|
|
25
|
+
// do nothing
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const demo = new Demo();
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
With `emitDecoratorMetadata` not set to true (default) the emitted JavaScript is:
|
|
33
|
+
|
|
34
|
+
```ts twoslash
|
|
35
|
+
// @experimentalDecorators
|
|
36
|
+
// @showEmit
|
|
37
|
+
function LogMethod(
|
|
38
|
+
target: any,
|
|
39
|
+
propertyKey: string | symbol,
|
|
40
|
+
descriptor: PropertyDescriptor,
|
|
41
|
+
) {
|
|
42
|
+
console.log(target);
|
|
43
|
+
console.log(propertyKey);
|
|
44
|
+
console.log(descriptor);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
class Demo {
|
|
48
|
+
@LogMethod
|
|
49
|
+
public foo(bar: number) {
|
|
50
|
+
// do nothing
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const demo = new Demo();
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
With `emitDecoratorMetadata` set to true the emitted JavaScript is:
|
|
58
|
+
|
|
59
|
+
```ts twoslash
|
|
60
|
+
// @experimentalDecorators
|
|
61
|
+
// @showEmit
|
|
62
|
+
// @emitDecoratorMetadata
|
|
63
|
+
function LogMethod(
|
|
64
|
+
target: any,
|
|
65
|
+
propertyKey: string | symbol,
|
|
66
|
+
descriptor: PropertyDescriptor,
|
|
67
|
+
) {
|
|
68
|
+
console.log(target);
|
|
69
|
+
console.log(propertyKey);
|
|
70
|
+
console.log(descriptor);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
class Demo {
|
|
74
|
+
@LogMethod
|
|
75
|
+
public foo(bar: number) {
|
|
76
|
+
// do nothing
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const demo = new Demo();
|
|
81
|
+
```
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Erasable Syntax Only'
|
|
3
|
+
oneline: 'Do not allow runtime constructs that are not part of ECMAScript.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Node.js [supports running TypeScript files directly](https://nodejs.org/api/typescript.html#type-stripping) as of v23.6;
|
|
7
|
+
however, only TypeScript-specific syntax that does not have runtime semantics are supported under this mode.
|
|
8
|
+
In other words, it must be possible to easily _erase_ any TypeScript-specific syntax from a file, leaving behind a valid JavaScript file.
|
|
9
|
+
|
|
10
|
+
That means the following constructs are not supported:
|
|
11
|
+
|
|
12
|
+
- `enum` declarations
|
|
13
|
+
- `namespace`s and `module`s with runtime code
|
|
14
|
+
- parameter properties in classes
|
|
15
|
+
- Non-ECMAScript `import =` and `export =` assignments
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
// ❌ error: An `import ... = require(...)` alias
|
|
19
|
+
import foo = require('foo');
|
|
20
|
+
|
|
21
|
+
// ❌ error: A namespace with runtime code.
|
|
22
|
+
namespace container {
|
|
23
|
+
foo.method();
|
|
24
|
+
|
|
25
|
+
export type Bar = string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// ❌ error: An `import =` alias
|
|
29
|
+
import Bar = container.Bar;
|
|
30
|
+
|
|
31
|
+
class Point {
|
|
32
|
+
// ❌ error: Parameter properties
|
|
33
|
+
constructor(
|
|
34
|
+
public x: number,
|
|
35
|
+
public y: number,
|
|
36
|
+
) {}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// ❌ error: An `export =` assignment.
|
|
40
|
+
export = Point;
|
|
41
|
+
|
|
42
|
+
// ❌ error: An enum declaration.
|
|
43
|
+
enum Direction {
|
|
44
|
+
Up,
|
|
45
|
+
Down,
|
|
46
|
+
Left,
|
|
47
|
+
Right,
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Similar tools like [ts-blank-space](https://github.com/bloomberg/ts-blank-space) or [Amaro](https://github.com/nodejs/amaro) (the underlying library for type-stripping in Node.js) have the same limitations.
|
|
52
|
+
These tools will provide helpful error messages if they encounter code that doesn't meet these requirements, but you still won't find out your code doesn't work until you actually try to run it.
|
|
53
|
+
|
|
54
|
+
The `--erasableSyntaxOnly` flag will cause TypeScript to error on most TypeScript-specific constructs that have runtime behavior.
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
class C {
|
|
58
|
+
constructor(public x: number) { }
|
|
59
|
+
// ~~~~~~~~~~~~~~~~
|
|
60
|
+
// error! This syntax is not allowed when 'erasableSyntaxOnly' is enabled.
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Typically, you will want to combine this flag with the `--verbatimModuleSyntax`, which ensures that a module contains the appropriate import syntax, and that import elision does not take place.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'ES Module Interop'
|
|
3
|
+
oneline: 'Emit additional JavaScript to ease support for importing CommonJS modules. This enables [`allowSyntheticDefaultImports`](#allowSyntheticDefaultImports) for type compatibility.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
By default (with `esModuleInterop` false or not set) TypeScript treats CommonJS/AMD/UMD modules similar to ES6 modules. In doing this, there are two parts in particular which turned out to be flawed assumptions:
|
|
7
|
+
|
|
8
|
+
- a namespace import like `import * as moment from "moment"` acts the same as `const moment = require("moment")`
|
|
9
|
+
|
|
10
|
+
- a default import like `import moment from "moment"` acts the same as `const moment = require("moment").default`
|
|
11
|
+
|
|
12
|
+
This mis-match causes these two issues:
|
|
13
|
+
|
|
14
|
+
- the ES6 modules spec states that a namespace import (`import * as x`) can only be an object, by having TypeScript
|
|
15
|
+
treating it the same as `= require("x")` then TypeScript allowed for the import to be treated as a function and be callable. That's not valid according to the spec.
|
|
16
|
+
|
|
17
|
+
- while accurate to the ES6 modules spec, most libraries with CommonJS/AMD/UMD modules didn't conform as strictly as TypeScript's implementation.
|
|
18
|
+
|
|
19
|
+
Turning on `esModuleInterop` will fix both of these problems in the code transpiled by TypeScript. The first changes the behavior in the compiler, the second is fixed by two new helper functions which provide a shim to ensure compatibility in the emitted JavaScript:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import * as fs from 'fs';
|
|
23
|
+
import _ from 'lodash';
|
|
24
|
+
|
|
25
|
+
fs.readFileSync('file.txt', 'utf8');
|
|
26
|
+
_.chunk(['a', 'b', 'c', 'd'], 2);
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
With `esModuleInterop` disabled:
|
|
30
|
+
|
|
31
|
+
```ts twoslash
|
|
32
|
+
// @noErrors
|
|
33
|
+
// @showEmit
|
|
34
|
+
// @esModuleInterop: false
|
|
35
|
+
// @module: commonjs
|
|
36
|
+
import * as fs from 'fs';
|
|
37
|
+
import _ from 'lodash';
|
|
38
|
+
|
|
39
|
+
fs.readFileSync('file.txt', 'utf8');
|
|
40
|
+
_.chunk(['a', 'b', 'c', 'd'], 2);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
With `esModuleInterop` set to `true`:
|
|
44
|
+
|
|
45
|
+
```ts twoslash
|
|
46
|
+
// @noErrors
|
|
47
|
+
// @showEmit
|
|
48
|
+
// @esModuleInterop
|
|
49
|
+
// @module: commonjs
|
|
50
|
+
import * as fs from 'fs';
|
|
51
|
+
import _ from 'lodash';
|
|
52
|
+
|
|
53
|
+
fs.readFileSync('file.txt', 'utf8');
|
|
54
|
+
_.chunk(['a', 'b', 'c', 'd'], 2);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
_Note_: The namespace import `import * as fs from "fs"` only accounts for properties which [are owned](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty) (basically properties set on the object and not via the prototype chain) on the imported object. If the module you're importing defines its API using inherited properties, you need to use the default import form (`import fs from "fs"`), or disable `esModuleInterop`.
|
|
58
|
+
|
|
59
|
+
_Note_: You can make JS emit terser by enabling [`importHelpers`](#importHelpers):
|
|
60
|
+
|
|
61
|
+
```ts twoslash
|
|
62
|
+
// @noErrors
|
|
63
|
+
// @showEmit
|
|
64
|
+
// @esModuleInterop
|
|
65
|
+
// @importHelpers
|
|
66
|
+
// @module: commonjs
|
|
67
|
+
import * as fs from 'fs';
|
|
68
|
+
import _ from 'lodash';
|
|
69
|
+
|
|
70
|
+
fs.readFileSync('file.txt', 'utf8');
|
|
71
|
+
_.chunk(['a', 'b', 'c', 'd'], 2);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Enabling `esModuleInterop` will also enable [`allowSyntheticDefaultImports`](#allowSyntheticDefaultImports).
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Exact Optional Property Types'
|
|
3
|
+
oneline: 'Interpret optional property types as written, rather than adding `undefined`.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
With exactOptionalPropertyTypes enabled, TypeScript applies stricter rules around how it handles properties on `type` or `interfaces` which have a `?` prefix.
|
|
7
|
+
|
|
8
|
+
For example, this interface declares that there is a property which can be one of two strings: 'dark' or 'light' or it should not be in the object.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
interface UserDefaults {
|
|
12
|
+
// The absence of a value represents 'system'
|
|
13
|
+
colorThemeOverride?: 'dark' | 'light';
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Without this flag enabled, there are three values which you can set `colorThemeOverride` to be: "dark", "light" and `undefined`.
|
|
18
|
+
|
|
19
|
+
Setting the value to `undefined` will allow most JavaScript runtime checks for the existence to fail, which is effectively falsy. However, this isn't quite accurate; `colorThemeOverride: undefined` is not the same as `colorThemeOverride` not being defined. For example, `"colorThemeOverride" in settings` would have different behavior with `undefined` as the key compared to not being defined.
|
|
20
|
+
|
|
21
|
+
`exactOptionalPropertyTypes` makes TypeScript truly enforce the definition provided as an optional property:
|
|
22
|
+
|
|
23
|
+
```ts twoslash
|
|
24
|
+
// @exactOptionalPropertyTypes
|
|
25
|
+
// @errors: 2322 2412
|
|
26
|
+
interface UserDefaults {
|
|
27
|
+
colorThemeOverride?: 'dark' | 'light';
|
|
28
|
+
}
|
|
29
|
+
declare function getUserSettings(): UserDefaults;
|
|
30
|
+
// ---cut---
|
|
31
|
+
const settings = getUserSettings();
|
|
32
|
+
settings.colorThemeOverride = 'dark';
|
|
33
|
+
settings.colorThemeOverride = 'light';
|
|
34
|
+
|
|
35
|
+
// But not:
|
|
36
|
+
settings.colorThemeOverride = undefined;
|
|
37
|
+
```
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Exclude'
|
|
3
|
+
oneline: 'Filters results from the [`include`](#include) option.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Specifies an array of filenames or patterns that should be skipped when resolving [`include`](#include).
|
|
7
|
+
|
|
8
|
+
**Important**: `exclude` _only_ changes which files are included as a result of the [`include`](#include) setting.
|
|
9
|
+
A file specified by `exclude` can still become part of your codebase due to an `import` statement in your code, a `types` inclusion, a `/// <reference` directive, or being specified in the [`files`](#files) list.
|
|
10
|
+
|
|
11
|
+
It is not a mechanism that **prevents** a file from being included in the codebase - it simply changes what the [`include`](#include) setting finds.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Exclude Directories'
|
|
3
|
+
oneline: 'Remove a list of directories from the watch process.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
You can use [`excludeFiles`](#excludeFiles) to drastically reduce the number of files which are watched during `--watch`. This can be a useful way to reduce the number of open file which TypeScript tracks on Linux.
|
|
7
|
+
|
|
8
|
+
```json tsconfig
|
|
9
|
+
{
|
|
10
|
+
"watchOptions": {
|
|
11
|
+
"excludeDirectories": ["**/node_modules", "_build", "temp/*"]
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
```
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Exclude Files'
|
|
3
|
+
oneline: "Remove a list of files from the watch mode's processing."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
You can use `excludeFiles` to remove a set of specific files from the files which are watched.
|
|
7
|
+
|
|
8
|
+
```json tsconfig
|
|
9
|
+
{
|
|
10
|
+
"watchOptions": {
|
|
11
|
+
"excludeFiles": ["temp/file.ts"]
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
```
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Experimental Decorators'
|
|
3
|
+
oneline: 'Enable experimental support for TC39 stage 2 draft decorators.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Enables [experimental support for decorators](https://github.com/tc39/proposal-decorators), which is a version of decorators that predates the TC39 standardization process.
|
|
7
|
+
|
|
8
|
+
Decorators are a language feature which hasn't yet been fully ratified into the JavaScript specification.
|
|
9
|
+
This means that the implementation version in TypeScript may differ from the implementation in JavaScript when it it decided by TC39.
|
|
10
|
+
|
|
11
|
+
You can find out more about decorator support in TypeScript in [the handbook](/docs/handbook/decorators.html).
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Explain Files'
|
|
3
|
+
oneline: 'Print files read during the compilation including why it was included.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Print names of files which TypeScript sees as a part of your project and the reason they are part of the compilation.
|
|
7
|
+
|
|
8
|
+
For example, with this project of just a single `index.ts` file
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
example
|
|
12
|
+
├── index.ts
|
|
13
|
+
├── package.json
|
|
14
|
+
└── tsconfig.json
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Using a `tsconfig.json` which has `explainFiles` set to true:
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"compilerOptions": {
|
|
22
|
+
"target": "es5",
|
|
23
|
+
"module": "commonjs",
|
|
24
|
+
"explainFiles": true
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Running TypeScript against this folder would have output like this:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
❯ tsc
|
|
33
|
+
node_modules/typescript/lib/lib.d.ts
|
|
34
|
+
Default library for target 'es5'
|
|
35
|
+
node_modules/typescript/lib/lib.es5.d.ts
|
|
36
|
+
Library referenced via 'es5' from file 'node_modules/typescript/lib/lib.d.ts'
|
|
37
|
+
node_modules/typescript/lib/lib.dom.d.ts
|
|
38
|
+
Library referenced via 'dom' from file 'node_modules/typescript/lib/lib.d.ts'
|
|
39
|
+
node_modules/typescript/lib/lib.webworker.importscripts.d.ts
|
|
40
|
+
Library referenced via 'webworker.importscripts' from
|
|
41
|
+
file 'node_modules/typescript/lib/lib.d.ts'
|
|
42
|
+
node_modules/typescript/lib/lib.scripthost.d.ts
|
|
43
|
+
Library referenced via 'scripthost'
|
|
44
|
+
from file 'node_modules/typescript/lib/lib.d.ts'
|
|
45
|
+
index.ts
|
|
46
|
+
Matched by include pattern '**/*' in 'tsconfig.json'
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The output above show:
|
|
50
|
+
|
|
51
|
+
- The initial lib.d.ts lookup based on [`target`](#target), and the chain of `.d.ts` files which are referenced
|
|
52
|
+
- The `index.ts` file located via the default pattern of [`include`](#include)
|
|
53
|
+
|
|
54
|
+
This option is intended for debugging how a file has become a part of your compile.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Extended Diagnostics'
|
|
3
|
+
oneline: 'Output more detailed compiler performance information after building.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
You can use this flag to discover where TypeScript is spending its time when compiling.
|
|
7
|
+
This is a tool used for understanding the performance characteristics of your codebase overall.
|
|
8
|
+
|
|
9
|
+
You can learn more about how to measure and understand the output in the performance [section of the wiki](https://github.com/microsoft/TypeScript/wiki/Performance).
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Extends'
|
|
3
|
+
oneline: 'Specify one or more path or node module references to base configuration files from which settings are inherited.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
The value of `extends` is a string which contains a path to another configuration file to inherit from.
|
|
7
|
+
The path may use Node.js style resolution.
|
|
8
|
+
|
|
9
|
+
The configuration from the base file are loaded first, then overridden by those in the inheriting config file. All relative paths found in the configuration file will be resolved relative to the configuration file they originated in.
|
|
10
|
+
|
|
11
|
+
It's worth noting that [`files`](#files), [`include`](#include), and [`exclude`](#exclude) from the inheriting config file _overwrite_ those from the
|
|
12
|
+
base config file, and that circularity between configuration files is not allowed.
|
|
13
|
+
|
|
14
|
+
Currently, the only top-level property that is excluded from inheritance is [`references`](#references).
|
|
15
|
+
|
|
16
|
+
##### Example
|
|
17
|
+
|
|
18
|
+
`configs/base.json`:
|
|
19
|
+
|
|
20
|
+
```json tsconfig
|
|
21
|
+
{
|
|
22
|
+
"compilerOptions": {
|
|
23
|
+
"noImplicitAny": true,
|
|
24
|
+
"strictNullChecks": true
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`tsconfig.json`:
|
|
30
|
+
|
|
31
|
+
```json tsconfig
|
|
32
|
+
{
|
|
33
|
+
"extends": "./configs/base",
|
|
34
|
+
"files": ["main.ts", "supplemental.ts"]
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`tsconfig.nostrictnull.json`:
|
|
39
|
+
|
|
40
|
+
```json tsconfig
|
|
41
|
+
{
|
|
42
|
+
"extends": "./tsconfig",
|
|
43
|
+
"compilerOptions": {
|
|
44
|
+
"strictNullChecks": false
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Properties with relative paths found in the configuration file, which aren't excluded from inheritance, will be resolved relative to the configuration file they originated in.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Fallback Polling'
|
|
3
|
+
oneline: 'Specify what approach the watcher should use if the system runs out of native file watchers.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
When using file system events, this option specifies the polling strategy that gets used when the system runs out of native file watchers and/or doesn't support native file watchers.
|
|
7
|
+
|
|
8
|
+
- `fixedPollingInterval`: Check every file for changes several times a second at a fixed interval.
|
|
9
|
+
- `priorityPollingInterval`: Check every file for changes several times a second, but use heuristics to check certain types of files less frequently than others.
|
|
10
|
+
- `dynamicPriorityPolling`: Use a dynamic queue where less-frequently modified files will be checked less often.
|
|
11
|
+
- `synchronousWatchDirectory`: Disable deferred watching on directories. Deferred watching is useful when lots of file changes might occur at once (e.g. a change in `node_modules` from running `npm install`), but you might want to disable it with this flag for some less-common setups.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Files'
|
|
3
|
+
oneline: 'Include a list of files. This does not support glob patterns, as opposed to [`include`](#include).'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Specifies an allowlist of files to include in the program. An error occurs if any of the files can't be found.
|
|
7
|
+
|
|
8
|
+
```json tsconfig
|
|
9
|
+
{
|
|
10
|
+
"compilerOptions": {},
|
|
11
|
+
"files": [
|
|
12
|
+
"core.ts",
|
|
13
|
+
"sys.ts",
|
|
14
|
+
"types.ts",
|
|
15
|
+
"scanner.ts",
|
|
16
|
+
"parser.ts",
|
|
17
|
+
"utilities.ts",
|
|
18
|
+
"binder.ts",
|
|
19
|
+
"checker.ts",
|
|
20
|
+
"tsc.ts"
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
This is useful when you only have a small number of files and don't need to use a glob to reference many files.
|
|
26
|
+
If you need that then use [`include`](#include).
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Force Consistent Casing In File Names'
|
|
3
|
+
oneline: 'Ensure that casing is correct in imports.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
TypeScript follows the case sensitivity rules of the file system it's running on.
|
|
7
|
+
This can be problematic if some developers are working in a case-sensitive file system and others aren't.
|
|
8
|
+
If a file attempts to import `fileManager.ts` by specifying `./FileManager.ts` the file will be found in a case-insensitive file system, but not on a case-sensitive file system.
|
|
9
|
+
|
|
10
|
+
When this option is set, TypeScript will issue an error if a program tries to include a file by a casing different from the casing on disk.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Generate CPU Profile'
|
|
3
|
+
oneline: 'Emit a v8 CPU profile of the compiler run for debugging.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
This option gives you the chance to have TypeScript emit a v8 CPU profile during the compiler run. The CPU profile can provide insight into why your builds may be slow.
|
|
7
|
+
|
|
8
|
+
This option can only be used from the CLI via: `--generateCpuProfile tsc-output.cpuprofile`.
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
npm run tsc --generateCpuProfile tsc-output.cpuprofile
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
This file can be opened in a chromium based browser like Chrome or Edge Developer in [the CPU profiler](https://developers.google.com/web/tools/chrome-devtools/rendering-tools/js-execution) section.
|
|
15
|
+
You can learn more about understanding the compilers performance in the [TypeScript wiki section on performance](https://github.com/microsoft/TypeScript/wiki/Performance).
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Import Helpers'
|
|
3
|
+
oneline: 'Allow importing helper functions from tslib once per project, instead of including them per-file.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
For certain downleveling operations, TypeScript uses some helper code for operations like extending class, spreading arrays or objects, and async operations.
|
|
7
|
+
By default, these helpers are inserted into files which use them.
|
|
8
|
+
This can result in code duplication if the same helper is used in many different modules.
|
|
9
|
+
|
|
10
|
+
If the `importHelpers` flag is on, these helper functions are instead imported from the [tslib](https://www.npmjs.com/package/tslib) module.
|
|
11
|
+
You will need to ensure that the `tslib` module is able to be imported at runtime.
|
|
12
|
+
This only affects modules; global script files will not attempt to import modules.
|
|
13
|
+
|
|
14
|
+
For example, with this TypeScript:
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
export function fn(arr: number[]) {
|
|
18
|
+
const arr2 = [1, ...arr];
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Turning on [`downlevelIteration`](#downlevelIteration) and `importHelpers` is still false:
|
|
23
|
+
|
|
24
|
+
```ts twoslash
|
|
25
|
+
// @showEmit
|
|
26
|
+
// @target: ES5
|
|
27
|
+
// @downleveliteration
|
|
28
|
+
export function fn(arr: number[]) {
|
|
29
|
+
const arr2 = [1, ...arr];
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Then turning on both [`downlevelIteration`](#downlevelIteration) and `importHelpers`:
|
|
34
|
+
|
|
35
|
+
```ts twoslash
|
|
36
|
+
// @showEmit
|
|
37
|
+
// @target: ES5
|
|
38
|
+
// @downleveliteration
|
|
39
|
+
// @importhelpers
|
|
40
|
+
// @noErrors
|
|
41
|
+
export function fn(arr: number[]) {
|
|
42
|
+
const arr2 = [1, ...arr];
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
You can use [`noEmitHelpers`](#noEmitHelpers) when you provide your own implementations of these functions.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Imports Not Used As Values'
|
|
3
|
+
oneline: 'Specify emit/checking behavior for imports that are only used for types.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Deprecated in favor of [`verbatimModuleSyntax`](#verbatimModuleSyntax).
|
|
7
|
+
|
|
8
|
+
This flag controls how `import` works, there are 3 different options:
|
|
9
|
+
|
|
10
|
+
- `remove`: The default behavior of dropping `import` statements which only reference types.
|
|
11
|
+
|
|
12
|
+
- `preserve`: Preserves all `import` statements whose values or types are never used. This can cause imports/side-effects to be preserved.
|
|
13
|
+
|
|
14
|
+
- `error`: This preserves all imports (the same as the preserve option), but will error when a value import is only used as a type. This might be useful if you want to ensure no values are being accidentally imported, but still make side-effect imports explicit.
|
|
15
|
+
|
|
16
|
+
This flag works because you can use `import type` to explicitly create an `import` statement which should never be emitted into JavaScript.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Include'
|
|
3
|
+
oneline: 'Specify a list of glob patterns that match files to be included in compilation.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Specifies an array of filenames or patterns to include in the program.
|
|
7
|
+
These filenames are resolved relative to the directory containing the `tsconfig.json` file.
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"include": ["src/**/*", "tests/**/*"]
|
|
12
|
+
}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Which would include:
|
|
16
|
+
|
|
17
|
+
<!-- TODO: #135
|
|
18
|
+
```diff
|
|
19
|
+
.
|
|
20
|
+
- ├── scripts
|
|
21
|
+
- │ ├── lint.ts
|
|
22
|
+
- │ ├── update_deps.ts
|
|
23
|
+
- │ └── utils.ts
|
|
24
|
+
+ ├── src
|
|
25
|
+
+ │ ├── client
|
|
26
|
+
+ │ │ ├── index.ts
|
|
27
|
+
+ │ │ └── utils.ts
|
|
28
|
+
+ │ ├── server
|
|
29
|
+
+ │ │ └── index.ts
|
|
30
|
+
+ ├── tests
|
|
31
|
+
+ │ ├── app.test.ts
|
|
32
|
+
+ │ ├── utils.ts
|
|
33
|
+
+ │ └── tests.d.ts
|
|
34
|
+
- ├── package.json
|
|
35
|
+
- ├── tsconfig.json
|
|
36
|
+
- └── yarn.lock
|
|
37
|
+
``` -->
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
.
|
|
41
|
+
├── scripts ⨯
|
|
42
|
+
│ ├── lint.ts ⨯
|
|
43
|
+
│ ├── update_deps.ts ⨯
|
|
44
|
+
│ └── utils.ts ⨯
|
|
45
|
+
├── src ✓
|
|
46
|
+
│ ├── client ✓
|
|
47
|
+
│ │ ├── index.ts ✓
|
|
48
|
+
│ │ └── utils.ts ✓
|
|
49
|
+
│ ├── server ✓
|
|
50
|
+
│ │ └── index.ts ✓
|
|
51
|
+
├── tests ✓
|
|
52
|
+
│ ├── app.test.ts ✓
|
|
53
|
+
│ ├── utils.ts ✓
|
|
54
|
+
│ └── tests.d.ts ✓
|
|
55
|
+
├── package.json
|
|
56
|
+
├── tsconfig.json
|
|
57
|
+
└── yarn.lock
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
`include` and `exclude` support wildcard characters to make glob patterns:
|
|
61
|
+
|
|
62
|
+
- `*` matches zero or more characters (excluding directory separators)
|
|
63
|
+
- `?` matches any one character (excluding directory separators)
|
|
64
|
+
- `**/` matches any directory nested to any level
|
|
65
|
+
|
|
66
|
+
If the last path segment in a pattern does not contain a file extension or wildcard character, then it is treated as a directory, and files with supported extensions inside that directory are included (e.g. `.ts`, `.tsx`, and `.d.ts` by default, with `.js` and `.jsx` if [`allowJs`](#allowJs) is set to true).
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Incremental'
|
|
3
|
+
oneline: 'Save .tsbuildinfo files to allow for incremental compilation of projects.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Tells TypeScript to save information about the project graph from the last compilation to files stored on disk. This
|
|
7
|
+
creates a series of `.tsbuildinfo` files in the same folder as your compilation output. They are not used by your
|
|
8
|
+
JavaScript at runtime and can be safely deleted. You can read more about the flag in the [3.4 release notes](/docs/handbook/release-notes/typescript-3-4.html#faster-subsequent-builds-with-the---incremental-flag).
|
|
9
|
+
|
|
10
|
+
To control which folders you want to the files to be built to, use the config option [`tsBuildInfoFile`](#tsBuildInfoFile).
|