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,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Inline Source Map'
|
|
3
|
+
oneline: 'Include sourcemap files inside the emitted JavaScript.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
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.
|
|
7
|
+
Although this results in larger JS files, it can be convenient in some scenarios.
|
|
8
|
+
For example, you might want to debug JS files on a webserver that doesn't allow `.map` files to be served.
|
|
9
|
+
|
|
10
|
+
Mutually exclusive with [`sourceMap`](#sourceMap).
|
|
11
|
+
|
|
12
|
+
For example, with this TypeScript:
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
const helloWorld = 'hi';
|
|
16
|
+
console.log(helloWorld);
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Converts to this JavaScript:
|
|
20
|
+
|
|
21
|
+
```ts twoslash
|
|
22
|
+
// @showEmit
|
|
23
|
+
const helloWorld = 'hi';
|
|
24
|
+
console.log(helloWorld);
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Then enable building it with `inlineSourceMap` enabled there is a comment at the bottom of the file which includes
|
|
28
|
+
a source-map for the file.
|
|
29
|
+
|
|
30
|
+
```ts twoslash
|
|
31
|
+
// @inlineSourceMap
|
|
32
|
+
// @showEmit
|
|
33
|
+
const helloWorld = 'hi';
|
|
34
|
+
console.log(helloWorld);
|
|
35
|
+
```
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Inline Sources'
|
|
3
|
+
oneline: 'Include source code in the sourcemaps inside the emitted JavaScript.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
When set, TypeScript will include the original content of the `.ts` file as an embedded string in the source map (using the source map's `sourcesContent` property).
|
|
7
|
+
This is often useful in the same cases as [`inlineSourceMap`](#inlineSourceMap).
|
|
8
|
+
|
|
9
|
+
Requires either [`sourceMap`](#sourceMap) or [`inlineSourceMap`](#inlineSourceMap) to be set.
|
|
10
|
+
|
|
11
|
+
For example, with this TypeScript:
|
|
12
|
+
|
|
13
|
+
```ts twoslash
|
|
14
|
+
const helloWorld = 'hi';
|
|
15
|
+
console.log(helloWorld);
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
By default converts to this JavaScript:
|
|
19
|
+
|
|
20
|
+
```ts twoslash
|
|
21
|
+
// @showEmit
|
|
22
|
+
const helloWorld = 'hi';
|
|
23
|
+
console.log(helloWorld);
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Then enable building it with `inlineSources` and [`inlineSourceMap`](#inlineSourceMap) enabled there is a comment at the bottom of the file which includes
|
|
27
|
+
a source-map for the file.
|
|
28
|
+
Note that the end is different from the example in [`inlineSourceMap`](#inlineSourceMap) because the source-map now contains the original source code also.
|
|
29
|
+
|
|
30
|
+
```ts twoslash
|
|
31
|
+
// @inlineSources
|
|
32
|
+
// @inlineSourceMap
|
|
33
|
+
// @showEmit
|
|
34
|
+
const helloWorld = 'hi';
|
|
35
|
+
console.log(helloWorld);
|
|
36
|
+
```
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'isolatedDeclarations'
|
|
3
|
+
oneline: 'Require sufficient annotation on exports so other tools can trivially generate declaration files.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Require sufficient annotation on exports so other tools can trivially generate declaration files.
|
|
7
|
+
|
|
8
|
+
For more information, see the [5.5 release notes](/docs/handbook/release-notes/typescript-5-5.html#isolated-declarations)
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Isolated Modules'
|
|
3
|
+
oneline: 'Ensure that each file can be safely transpiled without relying on other imports.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
While you can use TypeScript to produce JavaScript code from TypeScript code, it's also common to use other transpilers such as [Babel](https://babeljs.io) to do this.
|
|
7
|
+
However, other transpilers only operate on a single file at a time, which means they can't apply code transforms that depend on understanding the full type system.
|
|
8
|
+
This restriction also applies to TypeScript's `ts.transpileModule` API which is used by some build tools.
|
|
9
|
+
|
|
10
|
+
These limitations can cause runtime problems with some TypeScript features like `const enum`s and `namespace`s.
|
|
11
|
+
Setting the `isolatedModules` flag tells TypeScript to warn you if you write certain code that can't be correctly interpreted by a single-file transpilation process.
|
|
12
|
+
|
|
13
|
+
It does not change the behavior of your code, or otherwise change the behavior of TypeScript's checking and emitting process.
|
|
14
|
+
|
|
15
|
+
Some examples of code which does not work when `isolatedModules` is enabled.
|
|
16
|
+
|
|
17
|
+
#### Exports of Non-Value Identifiers
|
|
18
|
+
|
|
19
|
+
In TypeScript, you can import a _type_ and then subsequently export it:
|
|
20
|
+
|
|
21
|
+
```ts twoslash
|
|
22
|
+
// @noErrors
|
|
23
|
+
import { someType, someFunction } from 'someModule';
|
|
24
|
+
|
|
25
|
+
someFunction();
|
|
26
|
+
|
|
27
|
+
export { someType, someFunction };
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Because there's no value for `someType`, the emitted `export` will not try to export it (this would be a runtime error in JavaScript):
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
export { someFunction };
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Single-file transpilers don't know whether `someType` produces a value or not, so it's an error to export a name that only refers to a type.
|
|
37
|
+
|
|
38
|
+
#### Non-Module Files
|
|
39
|
+
|
|
40
|
+
If `isolatedModules` is set, namespaces are only allowed in _modules_ (which means it has some form of `import`/`export`). An error occurs if a namespace is found in a non-module file:
|
|
41
|
+
|
|
42
|
+
```ts twoslash
|
|
43
|
+
// @errors: 1277
|
|
44
|
+
// @isolatedModules
|
|
45
|
+
namespace Instantiated {
|
|
46
|
+
export const x = 1;
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
This restriction doesn't apply to `.d.ts` files.
|
|
51
|
+
|
|
52
|
+
#### References to `const enum` members
|
|
53
|
+
|
|
54
|
+
In TypeScript, when you reference a `const enum` member, the reference is replaced by its actual value in the emitted JavaScript. Changing this TypeScript:
|
|
55
|
+
|
|
56
|
+
```ts twoslash
|
|
57
|
+
declare const enum Numbers {
|
|
58
|
+
Zero = 0,
|
|
59
|
+
One = 1,
|
|
60
|
+
}
|
|
61
|
+
console.log(Numbers.Zero + Numbers.One);
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
To this JavaScript:
|
|
65
|
+
|
|
66
|
+
```ts twoslash
|
|
67
|
+
// @showEmit
|
|
68
|
+
// @removeComments
|
|
69
|
+
declare const enum Numbers {
|
|
70
|
+
Zero = 0,
|
|
71
|
+
One = 1,
|
|
72
|
+
}
|
|
73
|
+
console.log(Numbers.Zero + Numbers.One);
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Without knowledge of the values of these members, other transpilers can't replace the references to `Numbers`, which would be a runtime error if left alone (since there are no `Numbers` object at runtime).
|
|
77
|
+
Because of this, when `isolatedModules` is set, it is an error to reference an ambient `const enum` member.
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'JSX'
|
|
3
|
+
oneline: 'Specify what JSX code is generated.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Controls how JSX constructs are emitted in JavaScript files.
|
|
7
|
+
This only affects output of JS files that started in `.tsx` files.
|
|
8
|
+
|
|
9
|
+
- `react-jsx`: Emit `.js` files with the JSX changed to `_jsx` calls optimized for production
|
|
10
|
+
- `react-jsxdev`: Emit `.js` files with the JSX changed to `_jsx` calls for development only
|
|
11
|
+
- `preserve`: Emit `.jsx` files with the JSX unchanged
|
|
12
|
+
- `react-native`: Emit `.js` files with the JSX unchanged
|
|
13
|
+
- `react`: Emit `.js` files with JSX changed to the equivalent `React.createElement` calls
|
|
14
|
+
|
|
15
|
+
### For example
|
|
16
|
+
|
|
17
|
+
This sample code:
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
export const HelloWorld = () => <h1>Hello world</h1>;
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
React: `"react-jsx"`<sup>[[1]](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html)</sup>
|
|
24
|
+
|
|
25
|
+
```tsx twoslash
|
|
26
|
+
declare module JSX {
|
|
27
|
+
interface Element {}
|
|
28
|
+
interface IntrinsicElements {
|
|
29
|
+
[s: string]: any;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// @showEmit
|
|
33
|
+
// @noErrors
|
|
34
|
+
// @jsx: react-jsx
|
|
35
|
+
export const HelloWorld = () => <h1>Hello world</h1>;
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
React dev transform: `"react-jsxdev"`<sup>[[1]](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html)</sup>
|
|
39
|
+
|
|
40
|
+
```tsx twoslash
|
|
41
|
+
declare module JSX {
|
|
42
|
+
interface Element {}
|
|
43
|
+
interface IntrinsicElements {
|
|
44
|
+
[s: string]: any;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// @showEmit
|
|
48
|
+
// @noErrors
|
|
49
|
+
// @jsx: react-jsxdev
|
|
50
|
+
export const HelloWorld = () => <h1>Hello world</h1>;
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Preserve: `"preserve"`
|
|
54
|
+
|
|
55
|
+
```tsx twoslash
|
|
56
|
+
declare module JSX {
|
|
57
|
+
interface Element {}
|
|
58
|
+
interface IntrinsicElements {
|
|
59
|
+
[s: string]: any;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// @showEmit
|
|
63
|
+
// @noErrors
|
|
64
|
+
// @jsx: preserve
|
|
65
|
+
export const HelloWorld = () => <h1>Hello world</h1>;
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
React Native: `"react-native"`
|
|
69
|
+
|
|
70
|
+
```tsx twoslash
|
|
71
|
+
declare module JSX {
|
|
72
|
+
interface Element {}
|
|
73
|
+
interface IntrinsicElements {
|
|
74
|
+
[s: string]: any;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// @showEmit
|
|
78
|
+
// @noErrors
|
|
79
|
+
// @jsx: react-native
|
|
80
|
+
export const HelloWorld = () => <h1>Hello world</h1>;
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Legacy React runtime: `"react"`
|
|
84
|
+
|
|
85
|
+
```tsx twoslash
|
|
86
|
+
declare module JSX {
|
|
87
|
+
interface Element {}
|
|
88
|
+
interface IntrinsicElements {
|
|
89
|
+
[s: string]: any;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// @showEmit
|
|
93
|
+
// @noErrors
|
|
94
|
+
export const HelloWorld = () => <h1>Hello world</h1>;
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
This option can be used on a per-file basis too using an `@jsxRuntime` comment.
|
|
98
|
+
|
|
99
|
+
Always use the classic runtime (`"react"`) for this file:
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
/* @jsxRuntime classic */
|
|
103
|
+
export const HelloWorld = () => <h1>Hello world</h1>;
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Always use the automatic runtime (`"react-jsx"`) for this file:
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
/* @jsxRuntime automatic */
|
|
110
|
+
export const HelloWorld = () => <h1>Hello world</h1>;
|
|
111
|
+
```
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'JSX Factory'
|
|
3
|
+
oneline: "Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Changes the function called in `.js` files when compiling JSX Elements using the classic JSX runtime.
|
|
7
|
+
The most common change is to use `"h"` or `"preact.h"` instead of the default `"React.createElement"` if using `preact`.
|
|
8
|
+
|
|
9
|
+
For example, this TSX file:
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { h } from 'preact';
|
|
13
|
+
|
|
14
|
+
const HelloWorld = () => <div>Hello</div>;
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
With `jsxFactory: "h"` looks like:
|
|
18
|
+
|
|
19
|
+
```tsx twoslash
|
|
20
|
+
// @showEmit
|
|
21
|
+
// @showEmittedFile: index.js
|
|
22
|
+
// @jsxFactory: h
|
|
23
|
+
// @noErrors
|
|
24
|
+
// @target: esnext
|
|
25
|
+
// @module: commonjs
|
|
26
|
+
|
|
27
|
+
import { h, Fragment } from 'preact';
|
|
28
|
+
|
|
29
|
+
const HelloWorld = () => <div>Hello</div>;
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
This option can be used on a per-file basis too similar to [Babel's `/** @jsx h */` directive](https://babeljs.io/docs/en/babel-plugin-transform-react-jsx#custom).
|
|
33
|
+
|
|
34
|
+
```tsx twoslash
|
|
35
|
+
/** @jsx h */
|
|
36
|
+
import { h } from 'preact';
|
|
37
|
+
|
|
38
|
+
const HelloWorld = () => <div>Hello</div>;
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The factory chosen will also affect where the `JSX` namespace is looked up (for type checking information) before falling back to the global one.
|
|
42
|
+
|
|
43
|
+
If the factory is defined as `React.createElement` (the default), the compiler will check for `React.JSX` before checking for a global `JSX`. If the factory is defined as `h`, it will check for `h.JSX` before a global `JSX`.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'JSX Fragment Factory'
|
|
3
|
+
oneline: "Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Specify the JSX fragment factory function to use when targeting react JSX emit with [`jsxFactory`](#jsxFactory) compiler option is specified, e.g. `Fragment`.
|
|
7
|
+
|
|
8
|
+
For example with this TSConfig:
|
|
9
|
+
|
|
10
|
+
```json tsconfig
|
|
11
|
+
{
|
|
12
|
+
"compilerOptions": {
|
|
13
|
+
"target": "esnext",
|
|
14
|
+
"module": "commonjs",
|
|
15
|
+
"jsx": "react",
|
|
16
|
+
"jsxFactory": "h",
|
|
17
|
+
"jsxFragmentFactory": "Fragment"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
This TSX file:
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { h, Fragment } from 'preact';
|
|
26
|
+
|
|
27
|
+
const HelloWorld = () => (
|
|
28
|
+
<>
|
|
29
|
+
<div>Hello</div>
|
|
30
|
+
</>
|
|
31
|
+
);
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Would look like:
|
|
35
|
+
|
|
36
|
+
```tsx twoslash
|
|
37
|
+
// @showEmit
|
|
38
|
+
// @showEmittedFile: index.js
|
|
39
|
+
// @jsxFactory: h
|
|
40
|
+
// @jsxFragmentFactory: Fragment
|
|
41
|
+
// @noErrors
|
|
42
|
+
// @target: esnext
|
|
43
|
+
// @module: commonjs
|
|
44
|
+
|
|
45
|
+
import { h, Fragment } from 'preact';
|
|
46
|
+
|
|
47
|
+
const HelloWorld = () => (
|
|
48
|
+
<>
|
|
49
|
+
<div>Hello</div>
|
|
50
|
+
</>
|
|
51
|
+
);
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
This option can be used on a per-file basis too similar to [Babel's `/* @jsxFrag h */` directive](https://babeljs.io/docs/en/babel-plugin-transform-react-jsx#fragments).
|
|
55
|
+
|
|
56
|
+
For example:
|
|
57
|
+
|
|
58
|
+
```tsx twoslash
|
|
59
|
+
/** @jsx h */
|
|
60
|
+
/** @jsxFrag Fragment */
|
|
61
|
+
|
|
62
|
+
import { h, Fragment } from 'preact';
|
|
63
|
+
|
|
64
|
+
const HelloWorld = () => (
|
|
65
|
+
<>
|
|
66
|
+
<div>Hello</div>
|
|
67
|
+
</>
|
|
68
|
+
);
|
|
69
|
+
```
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'JSX Import Source'
|
|
3
|
+
oneline: 'Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Declares the module specifier to be used for importing the `jsx` and `jsxs` factory functions when using [`jsx`](#jsx) as `"react-jsx"` or `"react-jsxdev"` which were introduced in TypeScript 4.1.
|
|
7
|
+
|
|
8
|
+
With [React 17](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html) the library supports a new form of JSX transformation via a separate import.
|
|
9
|
+
|
|
10
|
+
For example with this code:
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
import React from 'react';
|
|
14
|
+
|
|
15
|
+
function App() {
|
|
16
|
+
return <h1>Hello World</h1>;
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Using this TSConfig:
|
|
21
|
+
|
|
22
|
+
```json tsconfig
|
|
23
|
+
{
|
|
24
|
+
"compilerOptions": {
|
|
25
|
+
"target": "esnext",
|
|
26
|
+
"module": "commonjs",
|
|
27
|
+
"jsx": "react-jsx"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The emitted JavaScript from TypeScript is:
|
|
33
|
+
|
|
34
|
+
```tsx twoslash
|
|
35
|
+
// @showEmit
|
|
36
|
+
// @noErrors
|
|
37
|
+
// @jsx: react-jsx
|
|
38
|
+
// @module: commonjs
|
|
39
|
+
// @target: esnext
|
|
40
|
+
declare module JSX {
|
|
41
|
+
interface Element {}
|
|
42
|
+
interface IntrinsicElements {
|
|
43
|
+
[s: string]: any;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
import React from 'react';
|
|
47
|
+
|
|
48
|
+
function App() {
|
|
49
|
+
return <h1>Hello World</h1>;
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
For example if you wanted to use `"jsxImportSource": "preact"`, you need a tsconfig like:
|
|
54
|
+
|
|
55
|
+
```json tsconfig
|
|
56
|
+
{
|
|
57
|
+
"compilerOptions": {
|
|
58
|
+
"target": "esnext",
|
|
59
|
+
"module": "commonjs",
|
|
60
|
+
"jsx": "react-jsx",
|
|
61
|
+
"jsxImportSource": "preact",
|
|
62
|
+
"types": ["preact"]
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Which generates code like:
|
|
68
|
+
|
|
69
|
+
```tsx twoslash
|
|
70
|
+
// @showEmit
|
|
71
|
+
// @jsxImportSource: preact
|
|
72
|
+
// @types: preact
|
|
73
|
+
// @jsx: react-jsx
|
|
74
|
+
// @target: esnext
|
|
75
|
+
// @module: commonjs
|
|
76
|
+
// @noErrors
|
|
77
|
+
|
|
78
|
+
export function App() {
|
|
79
|
+
return <h1>Hello World</h1>;
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Alternatively, you can use a per-file pragma to set this option, for example:
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
/** @jsxImportSource preact */
|
|
87
|
+
|
|
88
|
+
export function App() {
|
|
89
|
+
return <h1>Hello World</h1>;
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Would add `preact/jsx-runtime` as an import for the `_jsx` factory.
|
|
94
|
+
|
|
95
|
+
_Note:_ In order for this to work like you would expect, your `tsx` file must include an `export` or `import` so that it is considered a module.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Keyof Strings Only'
|
|
3
|
+
oneline: 'Make keyof only return strings instead of string, numbers or symbols. Legacy option.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
This flag changes the `keyof` type operator to return `string` instead of `string | number` when applied to a type with a string index signature.
|
|
7
|
+
|
|
8
|
+
This flag is used to help people keep this behavior from [before TypeScript 2.9's release](/docs/handbook/release-notes/typescript-2-9.html#support-number-and-symbol-named-properties-with-keyof-and-mapped-types).
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Lib'
|
|
3
|
+
oneline: 'Specify a set of bundled library declaration files that describe the target runtime environment.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
TypeScript includes a default set of type definitions for built-in JS APIs (like `Math`), as well as type definitions for things found in browser environments (like `document`).
|
|
7
|
+
TypeScript also includes APIs for newer JS features matching the [`target`](#target) you specify; for example the definition for `Map` is available if [`target`](#target) is `ES6` or newer.
|
|
8
|
+
|
|
9
|
+
You may want to change these for a few reasons:
|
|
10
|
+
|
|
11
|
+
- Your program doesn't run in a browser, so you don't want the `"dom"` type definitions
|
|
12
|
+
- Your runtime platform provides certain JavaScript API objects (maybe through polyfills), but doesn't yet support the full syntax of a given ECMAScript version
|
|
13
|
+
- You have polyfills or native implementations for some, but not all, of a higher level ECMAScript version
|
|
14
|
+
|
|
15
|
+
In TypeScript 4.5, lib files can be overridden by npm modules, find out more [in the blog](https://devblogs.microsoft.com/typescript/announcing-typescript-4-5-beta/#supporting-lib-from-node_modules).
|
|
16
|
+
|
|
17
|
+
### High Level libraries
|
|
18
|
+
|
|
19
|
+
| Name | Contents |
|
|
20
|
+
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
21
|
+
| `ES5` | Core definitions for all ES5 functionality |
|
|
22
|
+
| `ES2015` | Additional APIs available in ES2015 (also known as ES6) - `array.find`, `Promise`, `Proxy`, `Symbol`, `Map`, `Set`, `Reflect`, etc. |
|
|
23
|
+
| `ES6` | Alias for "ES2015" |
|
|
24
|
+
| `ES2016` | Additional APIs available in ES2016 - `array.include`, etc. |
|
|
25
|
+
| `ES7` | Alias for "ES2016" |
|
|
26
|
+
| `ES2017` | Additional APIs available in ES2017 - `Object.entries`, `Object.values`, `Atomics`, `SharedArrayBuffer`, `date.formatToParts`, typed arrays, etc. |
|
|
27
|
+
| `ES2018` | Additional APIs available in ES2018 - `async` iterables, `promise.finally`, `Intl.PluralRules`, `regexp.groups`, etc. |
|
|
28
|
+
| `ES2019` | Additional APIs available in ES2019 - `array.flat`, `array.flatMap`, `Object.fromEntries`, `string.trimStart`, `string.trimEnd`, etc. |
|
|
29
|
+
| `ES2020` | Additional APIs available in ES2020 - `string.matchAll`, etc. |
|
|
30
|
+
| `ES2021` | Additional APIs available in ES2021 - `promise.any`, `string.replaceAll` etc. |
|
|
31
|
+
| `ES2022` | Additional APIs available in ES2022 - `array.at`, `RegExp.hasIndices`, etc. |
|
|
32
|
+
| `ES2023` | Additional APIs available in ES2023 - `array.with`, `array.findLast`, `array.findLastIndex`, `array.toSorted`, `array.toReversed`, etc. |
|
|
33
|
+
| `ESNext` | Additional APIs available in ESNext - This changes as the JavaScript specification evolves |
|
|
34
|
+
| `DOM` | [DOM](https://developer.mozilla.org/docs/Glossary/DOM) definitions - `window`, `document`, etc. |
|
|
35
|
+
| `WebWorker` | APIs available in [WebWorker](https://developer.mozilla.org/docs/Web/API/Web_Workers_API/Using_web_workers) contexts |
|
|
36
|
+
| `ScriptHost` | APIs for the [Windows Script Hosting System](https://wikipedia.org/wiki/Windows_Script_Host) |
|
|
37
|
+
|
|
38
|
+
### Individual library components
|
|
39
|
+
|
|
40
|
+
| Name |
|
|
41
|
+
| ------------------------- |
|
|
42
|
+
| `DOM.Iterable` |
|
|
43
|
+
| `ES2015.Core` |
|
|
44
|
+
| `ES2015.Collection` |
|
|
45
|
+
| `ES2015.Generator` |
|
|
46
|
+
| `ES2015.Iterable` |
|
|
47
|
+
| `ES2015.Promise` |
|
|
48
|
+
| `ES2015.Proxy` |
|
|
49
|
+
| `ES2015.Reflect` |
|
|
50
|
+
| `ES2015.Symbol` |
|
|
51
|
+
| `ES2015.Symbol.WellKnown` |
|
|
52
|
+
| `ES2016.Array.Include` |
|
|
53
|
+
| `ES2017.object` |
|
|
54
|
+
| `ES2017.Intl` |
|
|
55
|
+
| `ES2017.SharedMemory` |
|
|
56
|
+
| `ES2017.String` |
|
|
57
|
+
| `ES2017.TypedArrays` |
|
|
58
|
+
| `ES2018.Intl` |
|
|
59
|
+
| `ES2018.Promise` |
|
|
60
|
+
| `ES2018.RegExp` |
|
|
61
|
+
| `ES2019.Array` |
|
|
62
|
+
| `ES2019.Object` |
|
|
63
|
+
| `ES2019.String` |
|
|
64
|
+
| `ES2019.Symbol` |
|
|
65
|
+
| `ES2020.String` |
|
|
66
|
+
| `ES2020.Symbol.wellknown` |
|
|
67
|
+
| `ES2021.Promise` |
|
|
68
|
+
| `ES2021.String` |
|
|
69
|
+
| `ES2021.WeakRef` |
|
|
70
|
+
| `ESNext.AsyncIterable` |
|
|
71
|
+
| `ESNext.Array` |
|
|
72
|
+
| `ESNext.Intl` |
|
|
73
|
+
| `ESNext.Symbol` |
|
|
74
|
+
|
|
75
|
+
This list may be out of date, you can see the full list in the [TypeScript source code](https://github.com/microsoft/TypeScript/tree/main/src/lib).
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'Lib Replacement'
|
|
3
|
+
oneline: 'Enable substitution of default `lib` files with custom ones.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
TypeScript 4.5 introduced the possibility of substituting the default `lib` files with custom ones.
|
|
7
|
+
All built-in library files would first try to be resolved from packages named `@typescript/lib-*`.
|
|
8
|
+
For example, you could lock your `dom` libraries onto a specific version of [the `@types/web` package](https://www.npmjs.com/package/@types/web?activeTab=readme) with the following `package.json`:
|
|
9
|
+
|
|
10
|
+
```json
|
|
11
|
+
{
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"@typescript/lib-dom": "npm:@types/web@0.0.199"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
When installed, a package called `@typescript/lib-dom` should exist, and TypeScript would always look there when searching for `lib.dom.d.ts`.
|
|
19
|
+
|
|
20
|
+
The `--libReplacement` flag allows you to disable this behavior.
|
|
21
|
+
If you're not using any `@typescript/lib-*` packages, you can now disable those package lookups with `--libReplacement false`.
|
|
22
|
+
In the future, `--libReplacement false` may become the default, so if you currently rely on the behavior you should consider explicitly enabling it with `--libReplacement true`.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'List Emitted Files'
|
|
3
|
+
oneline: 'Print the names of emitted files after a compilation.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Print names of generated files part of the compilation to the terminal.
|
|
7
|
+
|
|
8
|
+
This flag is useful in two cases:
|
|
9
|
+
|
|
10
|
+
- You want to transpile TypeScript as a part of a build chain in the terminal where the filenames are processed in the next command.
|
|
11
|
+
- You are not sure that TypeScript has included a file you expected, as a part of debugging the [file inclusion settings](#Project_Files_0).
|
|
12
|
+
|
|
13
|
+
For example:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
example
|
|
17
|
+
├── index.ts
|
|
18
|
+
├── package.json
|
|
19
|
+
└── tsconfig.json
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
With:
|
|
23
|
+
|
|
24
|
+
```json tsconfig
|
|
25
|
+
{
|
|
26
|
+
"compilerOptions": {
|
|
27
|
+
"declaration": true,
|
|
28
|
+
"listEmittedFiles": true
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Would echo paths like:
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
$ npm run tsc
|
|
37
|
+
|
|
38
|
+
path/to/example/index.js
|
|
39
|
+
path/to/example/index.d.ts
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Normally, TypeScript would return silently on success.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
display: 'List Files'
|
|
3
|
+
oneline: 'Print all of the files read during the compilation.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Print names of files part of the compilation. This is useful when you are not sure that TypeScript has
|
|
7
|
+
included a file you expected.
|
|
8
|
+
|
|
9
|
+
For example:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
example
|
|
13
|
+
├── index.ts
|
|
14
|
+
├── package.json
|
|
15
|
+
└── tsconfig.json
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
With:
|
|
19
|
+
|
|
20
|
+
```json tsconfig
|
|
21
|
+
{
|
|
22
|
+
"compilerOptions": {
|
|
23
|
+
"listFiles": true
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Would echo paths like:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
$ npm run tsc
|
|
32
|
+
path/to/example/node_modules/typescript/lib/lib.d.ts
|
|
33
|
+
path/to/example/node_modules/typescript/lib/lib.es5.d.ts
|
|
34
|
+
path/to/example/node_modules/typescript/lib/lib.dom.d.ts
|
|
35
|
+
path/to/example/node_modules/typescript/lib/lib.webworker.importscripts.d.ts
|
|
36
|
+
path/to/example/node_modules/typescript/lib/lib.scripthost.d.ts
|
|
37
|
+
path/to/example/index.ts
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Note if using TypeScript 4.2, prefer [`explainFiles`](#explainFiles) which offers an explanation of why a file was added too.
|