ai-hero-cli 0.0.3 → 0.0.5
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/dist/bin.d.ts +1 -0
- package/dist/bin.js +1 -1
- package/dist/bin.js.map +1 -1
- 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,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Source Map'
|
|
3
|
+
oneline: 'Create source map files for emitted JavaScript files.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Enables the generation of [sourcemap files](https://developer.mozilla.org/docs/Tools/Debugger/How_to/Use_a_source_map).
|
|
7
|
+
These files allow debuggers and other tools to display the original TypeScript source code when actually working with the emitted JavaScript files.
|
|
8
|
+
Source map files are emitted as `.js.map` (or `.jsx.map`) files next to the corresponding `.js` output file.
|
|
9
|
+
|
|
10
|
+
The `.js` files will in turn contain a sourcemap comment to indicate where the files are to external tools, for example:
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
// helloWorld.ts
|
|
14
|
+
export declare const helloWorld = 'hi';
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Compiling with `sourceMap` set to `true` creates the following JavaScript file:
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
// helloWorld.js
|
|
21
|
+
'use strict';
|
|
22
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
23
|
+
exports.helloWorld = 'hi';
|
|
24
|
+
//# sourceMappingURL=// helloWorld.js.map
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
And this also generates this json map:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
// helloWorld.js.map
|
|
31
|
+
{
|
|
32
|
+
"version": 3,
|
|
33
|
+
"file": "ex.js",
|
|
34
|
+
"sourceRoot": "",
|
|
35
|
+
"sources": ["../ex.ts"],
|
|
36
|
+
"names": [],
|
|
37
|
+
"mappings": ";;AAAa,QAAA,UAAU,GAAG,IAAI,CAAA"
|
|
38
|
+
}
|
|
39
|
+
```
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Source Root'
|
|
3
|
+
oneline: 'Specify the root path for debuggers to find the reference source code.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Specify the location where a debugger should locate TypeScript files instead of relative source locations.
|
|
7
|
+
This string is treated verbatim inside the source-map where you can use a path or a URL:
|
|
8
|
+
|
|
9
|
+
```json tsconfig
|
|
10
|
+
{
|
|
11
|
+
"compilerOptions": {
|
|
12
|
+
"sourceMap": true,
|
|
13
|
+
"sourceRoot": "https://my-website.com/debug/source/"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Would declare that `index.js` will have a source file at `https://my-website.com/debug/source/index.ts`.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Strict'
|
|
3
|
+
oneline: 'Enable all strict type-checking options.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
The `strict` flag enables a wide range of type checking behavior that results in stronger guarantees of program correctness.
|
|
7
|
+
Turning this on is equivalent to enabling all of the _strict mode family_ options, which are outlined below.
|
|
8
|
+
You can then turn off individual strict mode family checks as needed.
|
|
9
|
+
|
|
10
|
+
Future versions of TypeScript may introduce additional stricter checking under this flag, so upgrades of TypeScript might result in new type errors in your program.
|
|
11
|
+
When appropriate and possible, a corresponding flag will be added to disable that behavior.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Strict Bind Call Apply'
|
|
3
|
+
oneline: 'Check that the arguments for `bind`, `call`, and `apply` methods match the original function.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
When set, TypeScript will check that the built-in methods of functions `call`, `bind`, and `apply` are invoked with correct argument for the underlying function:
|
|
7
|
+
|
|
8
|
+
```ts twoslash
|
|
9
|
+
// @strictBindCallApply: true
|
|
10
|
+
// @errors: 2345
|
|
11
|
+
|
|
12
|
+
// With strictBindCallApply on
|
|
13
|
+
function fn(x: string) {
|
|
14
|
+
return parseInt(x);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const n1 = fn.call(undefined, '10');
|
|
18
|
+
|
|
19
|
+
const n2 = fn.call(undefined, false);
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Otherwise, these functions accept any arguments and will return `any`:
|
|
23
|
+
|
|
24
|
+
```ts twoslash
|
|
25
|
+
// @strictBindCallApply: false
|
|
26
|
+
|
|
27
|
+
// With strictBindCallApply off
|
|
28
|
+
function fn(x: string) {
|
|
29
|
+
return parseInt(x);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Note: No error; return type is 'any'
|
|
33
|
+
const n = fn.call(undefined, false);
|
|
34
|
+
```
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Strict Function Types'
|
|
3
|
+
oneline: 'When assigning functions, check to ensure parameters and the return values are subtype-compatible.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
When enabled, this flag causes functions parameters to be checked more correctly.
|
|
7
|
+
|
|
8
|
+
Here's a basic example with `strictFunctionTypes` off:
|
|
9
|
+
|
|
10
|
+
```ts twoslash
|
|
11
|
+
// @strictFunctionTypes: false
|
|
12
|
+
function fn(x: string) {
|
|
13
|
+
console.log('Hello, ' + x.toLowerCase());
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type StringOrNumberFunc = (ns: string | number) => void;
|
|
17
|
+
|
|
18
|
+
// Unsafe assignment
|
|
19
|
+
let func: StringOrNumberFunc = fn;
|
|
20
|
+
// Unsafe call - will crash
|
|
21
|
+
func(10);
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
With `strictFunctionTypes` _on_, the error is correctly detected:
|
|
25
|
+
|
|
26
|
+
```ts twoslash
|
|
27
|
+
// @errors: 2322
|
|
28
|
+
function fn(x: string) {
|
|
29
|
+
console.log('Hello, ' + x.toLowerCase());
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
type StringOrNumberFunc = (ns: string | number) => void;
|
|
33
|
+
|
|
34
|
+
// Unsafe assignment is prevented
|
|
35
|
+
let func: StringOrNumberFunc = fn;
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
During development of this feature, we discovered a large number of inherently unsafe class hierarchies, including some in the DOM.
|
|
39
|
+
Because of this, the setting only applies to functions written in _function_ syntax, not to those in _method_ syntax:
|
|
40
|
+
|
|
41
|
+
```ts twoslash
|
|
42
|
+
type Methodish = {
|
|
43
|
+
func(x: string | number): void;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
function fn(x: string) {
|
|
47
|
+
console.log('Hello, ' + x.toLowerCase());
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Ultimately an unsafe assignment, but not detected
|
|
51
|
+
const m: Methodish = {
|
|
52
|
+
func: fn,
|
|
53
|
+
};
|
|
54
|
+
m.func(10);
|
|
55
|
+
```
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Strict Null Checks'
|
|
3
|
+
oneline: 'When type checking, take into account `null` and `undefined`.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
When `strictNullChecks` is `false`, `null` and `undefined` are effectively ignored by the language.
|
|
7
|
+
This can lead to unexpected errors at runtime.
|
|
8
|
+
|
|
9
|
+
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.
|
|
10
|
+
|
|
11
|
+
For example with this TypeScript code, `users.find` has no guarantee that it will actually find a user, but you can
|
|
12
|
+
write code as though it will:
|
|
13
|
+
|
|
14
|
+
```ts twoslash
|
|
15
|
+
// @strictNullChecks: false
|
|
16
|
+
// @target: ES2015
|
|
17
|
+
declare const loggedInUsername: string;
|
|
18
|
+
|
|
19
|
+
const users = [
|
|
20
|
+
{ name: 'Oby', age: 12 },
|
|
21
|
+
{ name: 'Heera', age: 32 },
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
const loggedInUser = users.find((u) => u.name === loggedInUsername);
|
|
25
|
+
console.log(loggedInUser.age);
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Setting `strictNullChecks` to `true` will raise an error that you have not made a guarantee that the `loggedInUser` exists before trying to use it.
|
|
29
|
+
|
|
30
|
+
```ts twoslash
|
|
31
|
+
// @errors: 2339 2532 18048
|
|
32
|
+
// @target: ES2020
|
|
33
|
+
// @strictNullChecks
|
|
34
|
+
declare const loggedInUsername: string;
|
|
35
|
+
|
|
36
|
+
const users = [
|
|
37
|
+
{ name: 'Oby', age: 12 },
|
|
38
|
+
{ name: 'Heera', age: 32 },
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
const loggedInUser = users.find((u) => u.name === loggedInUsername);
|
|
42
|
+
console.log(loggedInUser.age);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The second example failed because the array's `find` function looks a bit like this simplification:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
// When strictNullChecks: true
|
|
49
|
+
type Array = {
|
|
50
|
+
find(predicate: (value: any, index: number) => boolean): S | undefined;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// When strictNullChecks: false the undefined is removed from the type system,
|
|
54
|
+
// allowing you to write code which assumes it always found a result
|
|
55
|
+
type Array = {
|
|
56
|
+
find(predicate: (value: any, index: number) => boolean): S;
|
|
57
|
+
};
|
|
58
|
+
```
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Strict Property Initialization'
|
|
3
|
+
oneline: 'Check for class properties that are declared but not set in the constructor.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
When set to true, TypeScript will raise an error when a class property was declared but not set in the constructor.
|
|
7
|
+
|
|
8
|
+
```ts twoslash
|
|
9
|
+
// @errors: 2564
|
|
10
|
+
class UserAccount {
|
|
11
|
+
name: string;
|
|
12
|
+
accountType = 'user';
|
|
13
|
+
|
|
14
|
+
email: string;
|
|
15
|
+
address: string | undefined;
|
|
16
|
+
|
|
17
|
+
constructor(name: string) {
|
|
18
|
+
this.name = name;
|
|
19
|
+
// Note that this.email is not set
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
In the above case:
|
|
25
|
+
|
|
26
|
+
- `this.name` is set specifically.
|
|
27
|
+
- `this.accountType` is set by default.
|
|
28
|
+
- `this.email` is not set and raises an error.
|
|
29
|
+
- `this.address` is declared as potentially `undefined` which means it does not have to be set.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Strip Internal'
|
|
3
|
+
oneline: 'Disable emitting declarations that have `@internal` in their JSDoc comments.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Do not emit declarations for code that has an `@internal` annotation in its JSDoc comment.
|
|
7
|
+
This is an internal compiler option; use at your own risk, because the compiler does not check that the result is valid.
|
|
8
|
+
If you are searching for a tool to handle additional levels of visibility within your `d.ts` files, look at [api-extractor](https://api-extractor.com).
|
|
9
|
+
|
|
10
|
+
```ts twoslash
|
|
11
|
+
/**
|
|
12
|
+
* Days available in a week
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export const daysInAWeek = 7;
|
|
16
|
+
|
|
17
|
+
/** Calculate how much someone earns in a week */
|
|
18
|
+
export function weeklySalary(dayRate: number) {
|
|
19
|
+
return daysInAWeek * dayRate;
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
With the flag set to `false` (default):
|
|
24
|
+
|
|
25
|
+
```ts twoslash
|
|
26
|
+
// @showEmittedFile: index.d.ts
|
|
27
|
+
// @showEmit
|
|
28
|
+
// @declaration
|
|
29
|
+
/**
|
|
30
|
+
* Days available in a week
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
export const daysInAWeek = 7;
|
|
34
|
+
|
|
35
|
+
/** Calculate how much someone earns in a week */
|
|
36
|
+
export function weeklySalary(dayRate: number) {
|
|
37
|
+
return daysInAWeek * dayRate;
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
With `stripInternal` set to `true` the `d.ts` emitted will be redacted.
|
|
42
|
+
|
|
43
|
+
```ts twoslash
|
|
44
|
+
// @stripinternal
|
|
45
|
+
// @showEmittedFile: index.d.ts
|
|
46
|
+
// @showEmit
|
|
47
|
+
// @declaration
|
|
48
|
+
/**
|
|
49
|
+
* Days available in a week
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
export const daysInAWeek = 7;
|
|
53
|
+
|
|
54
|
+
/** Calculate how much someone earns in a week */
|
|
55
|
+
export function weeklySalary(dayRate: number) {
|
|
56
|
+
return daysInAWeek * dayRate;
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The JavaScript output is still the same.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Suppress Excess Property Errors'
|
|
3
|
+
oneline: 'Disable reporting of excess property errors during the creation of object literals.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
This disables reporting of excess property errors, such as the one shown in the following example:
|
|
7
|
+
|
|
8
|
+
```ts twoslash
|
|
9
|
+
// @errors: 2322
|
|
10
|
+
type Point = { x: number; y: number };
|
|
11
|
+
const p: Point = { x: 1, y: 3, m: 10 };
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
This flag was added to help people migrate to the stricter checking of new object literals in [TypeScript 1.6](/docs/handbook/release-notes/typescript-1-6.html#stricter-object-literal-assignment-checks).
|
|
15
|
+
|
|
16
|
+
We don't recommend using this flag in a modern codebase, you can suppress one-off cases where you need it using `// @ts-ignore`.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Suppress Implicit Any Index Errors'
|
|
3
|
+
oneline: 'Suppress [`noImplicitAny`](#noImplicitAny) errors when indexing objects that lack index signatures.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Turning `suppressImplicitAnyIndexErrors` on suppresses reporting the error about implicit anys when indexing into objects, as shown in the following example:
|
|
7
|
+
|
|
8
|
+
```ts twoslash
|
|
9
|
+
// @noImplicitAny: true
|
|
10
|
+
// @suppressImplicitAnyIndexErrors: false
|
|
11
|
+
// @strict: true
|
|
12
|
+
// @errors: 7053
|
|
13
|
+
const obj = { x: 10 };
|
|
14
|
+
console.log(obj['foo']);
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Using `suppressImplicitAnyIndexErrors` is quite a drastic approach. It is recommended to use a `@ts-ignore` comment instead:
|
|
18
|
+
|
|
19
|
+
```ts twoslash
|
|
20
|
+
// @noImplicitAny: true
|
|
21
|
+
// @strict: true
|
|
22
|
+
const obj = { x: 10 };
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
console.log(obj['foo']);
|
|
25
|
+
```
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Synchronous Watch Directory'
|
|
3
|
+
oneline: 'Synchronously call callbacks and update the state of directory watchers on platforms that don`t support recursive watching natively.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Synchronously call callbacks and update the state of directory watchers on platforms that don`t support recursive watching natively. Instead of giving a small timeout to allow for potentially multiple edits to occur on a file.
|
|
7
|
+
|
|
8
|
+
```json tsconfig
|
|
9
|
+
{
|
|
10
|
+
"watchOptions": {
|
|
11
|
+
"synchronousWatchDirectory": true
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
```
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Target'
|
|
3
|
+
oneline: 'Set the JavaScript language version for emitted JavaScript and include compatible library declarations.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Modern browsers support all ES6 features, so `ES6` is a good choice.
|
|
7
|
+
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.
|
|
8
|
+
|
|
9
|
+
The `target` setting changes which JS features are downleveled and which are left intact.
|
|
10
|
+
For example, an arrow function `() => this` will be turned into an equivalent `function` expression if `target` is ES5 or lower.
|
|
11
|
+
|
|
12
|
+
Changing `target` also changes the default value of [`lib`](#lib).
|
|
13
|
+
You may "mix and match" `target` and `lib` settings as desired, but you could just set `target` for convenience.
|
|
14
|
+
|
|
15
|
+
For developer platforms like Node there are baselines for the `target`, depending on the type of platform and its version. You can find a set of community organized TSConfigs at [tsconfig/bases](https://github.com/tsconfig/bases#centralized-recommendations-for-tsconfig-bases), which has configurations for common platforms and their versions.
|
|
16
|
+
|
|
17
|
+
The special `ESNext` value refers to the highest version your version of TypeScript supports.
|
|
18
|
+
This setting should be used with caution, since it doesn't mean the same thing between different TypeScript versions and can make upgrades less predictable.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Trace Resolution'
|
|
3
|
+
oneline: 'Log paths used during the [`moduleResolution`](#moduleResolution) process.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
When you are trying to debug why a module isn't being included.
|
|
7
|
+
You can set `traceResolution` to `true` to have TypeScript print information about its resolution process for each processed file.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'TS Build Info File'
|
|
3
|
+
oneline: 'The file to store `.tsbuildinfo` incremental build information in.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
This setting lets you specify a file for storing incremental compilation information as a part of composite projects which enables faster
|
|
7
|
+
building of larger TypeScript codebases. You can read more about composite projects [in the handbook](/docs/handbook/project-references.html).
|
|
8
|
+
|
|
9
|
+
The default depends on a combination of other settings:
|
|
10
|
+
|
|
11
|
+
- If `outFile` is set, the default is `<outFile>.tsbuildinfo`.
|
|
12
|
+
- If `rootDir` and `outDir` are set, then the file is `<outDir>/<relative path to config from rootDir>/<config name>.tsbuildinfo`
|
|
13
|
+
For example, if `rootDir` is `src`, `outDir` is `dest`, and the config is
|
|
14
|
+
`./tsconfig.json`, then the default is `./tsconfig.tsbuildinfo`
|
|
15
|
+
as the relative path from `src/` to `./tsconfig.json` is `../`.
|
|
16
|
+
- If `outDir` is set, then the default is `<outDir>/<config name>.tsbuildInfo`
|
|
17
|
+
- Otherwise, the default is `<config name>.tsbuildInfo`
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Type Acquisition'
|
|
3
|
+
oneline: 'Specify options for automatic acquisition of declaration files.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
When you have a JavaScript project in your editor, TypeScript will provide types for your `node_modules` automatically using the DefinitelyTyped set of `@types` definitions.
|
|
7
|
+
This is called automatic type acquisition, and you can customize it using the `typeAcquisition` object in your configuration.
|
|
8
|
+
|
|
9
|
+
If you would like to disable or customize this feature, create a `jsconfig.json` in the root of your project:
|
|
10
|
+
|
|
11
|
+
```json
|
|
12
|
+
{
|
|
13
|
+
"typeAcquisition": {
|
|
14
|
+
"enable": false
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
If you have a specific module which should be included (but isn't in `node_modules`):
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"typeAcquisition": {
|
|
24
|
+
"include": ["jest"]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
If a module should not be automatically acquired, for example if the library is available in your `node_modules` but your team has agreed to not use it:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"typeAcquisition": {
|
|
34
|
+
"exclude": ["jquery"]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Type Roots'
|
|
3
|
+
oneline: 'Specify multiple folders that act like `./node_modules/@types`.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
By default all _visible_ "`@types`" packages are included in your compilation.
|
|
7
|
+
Packages in `node_modules/@types` of any enclosing folder are considered _visible_.
|
|
8
|
+
For example, that means packages within `./node_modules/@types/`, `../node_modules/@types/`, `../../node_modules/@types/`, and so on.
|
|
9
|
+
|
|
10
|
+
If `typeRoots` is specified, _only_ packages under `typeRoots` will be included. For example:
|
|
11
|
+
|
|
12
|
+
```json tsconfig
|
|
13
|
+
{
|
|
14
|
+
"compilerOptions": {
|
|
15
|
+
"typeRoots": ["./typings", "./vendor/types"]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
This config file will include _all_ packages under `./typings` and `./vendor/types`, and no packages from `./node_modules/@types`.
|
|
21
|
+
All paths are relative to the `tsconfig.json`.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Types'
|
|
3
|
+
oneline: 'Specify type package names to be included without being referenced in a source file.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
By default all _visible_ "`@types`" packages are included in your compilation.
|
|
7
|
+
Packages in `node_modules/@types` of any enclosing folder are considered _visible_.
|
|
8
|
+
For example, that means packages within `./node_modules/@types/`, `../node_modules/@types/`, `../../node_modules/@types/`, and so on.
|
|
9
|
+
|
|
10
|
+
If `types` is specified, only packages listed will be included in the global scope. For instance:
|
|
11
|
+
|
|
12
|
+
```json tsconfig
|
|
13
|
+
{
|
|
14
|
+
"compilerOptions": {
|
|
15
|
+
"types": ["node", "jest", "express"]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
This `tsconfig.json` file will _only_ include `./node_modules/@types/node`, `./node_modules/@types/jest` and `./node_modules/@types/express`.
|
|
21
|
+
Other packages under `node_modules/@types/*` will not be included.
|
|
22
|
+
|
|
23
|
+
### What does this affect?
|
|
24
|
+
|
|
25
|
+
This option does not affect how `@types/*` are included in your application code, for example if you had the above `compilerOptions` example with code like:
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import * as moment from 'moment';
|
|
29
|
+
|
|
30
|
+
moment().format('MMMM Do YYYY, h:mm:ss a');
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The `moment` import would be fully typed.
|
|
34
|
+
|
|
35
|
+
When you have this option set, by not including a module in the `types` array it:
|
|
36
|
+
|
|
37
|
+
- Will not add globals to your project (e.g `process` in node, or `expect` in Jest)
|
|
38
|
+
- Will not have exports appear as auto-import recommendations
|
|
39
|
+
|
|
40
|
+
This feature differs from [`typeRoots`](#typeRoots) in that it is about specifying only the exact types you want included, whereas [`typeRoots`](#typeRoots) supports saying you want particular folders.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Use Define For Class Fields'
|
|
3
|
+
oneline: 'Emit ECMAScript-standard-compliant class fields.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
This flag is used as part of migrating to the upcoming standard version of class fields. TypeScript introduced class fields many years before it was ratified in TC39. The latest version of the upcoming specification has a different runtime behavior to TypeScript's implementation but the same syntax.
|
|
7
|
+
|
|
8
|
+
This flag switches to the upcoming ECMA runtime behavior.
|
|
9
|
+
|
|
10
|
+
You can read more about the transition in [the 3.7 release notes](/docs/handbook/release-notes/typescript-3-7.html#the-usedefineforclassfields-flag-and-the-declare-property-modifier).
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Use Unknown In Catch Variables'
|
|
3
|
+
oneline: 'Default catch clause variables as `unknown` instead of `any`.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
In TypeScript 4.0, support was added to allow changing the type of the variable in a catch clause from `any` to `unknown`. Allowing for code like:
|
|
7
|
+
|
|
8
|
+
```ts twoslash
|
|
9
|
+
// @useUnknownInCatchVariables
|
|
10
|
+
try {
|
|
11
|
+
// ...
|
|
12
|
+
} catch (err: unknown) {
|
|
13
|
+
// We have to verify err is an
|
|
14
|
+
// error before using it as one.
|
|
15
|
+
if (err instanceof Error) {
|
|
16
|
+
console.log(err.message);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
This pattern ensures that error handling code becomes more comprehensive because you cannot guarantee that the object being thrown _is_ a Error subclass ahead of time. With the flag `useUnknownInCatchVariables` enabled, then you do not need the additional syntax (`: unknown`) nor a linter rule to try enforce this behavior.
|