ai-hero-cli 0.0.5 → 0.0.7
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/README.md +133 -2
- package/bin.js +67704 -0
- package/package.json +7 -50
- package/LICENSE +0 -21
- package/dist/bin.d.ts +0 -2
- package/dist/bin.js +0 -4
- package/dist/bin.js.map +0 -1
- package/dist/command.d.ts +0 -2
- package/dist/command.js +0 -114
- package/dist/command.js.map +0 -1
- package/dist/config.d.ts +0 -15
- package/dist/config.js +0 -52
- package/dist/config.js.map +0 -1
- package/dist/model.d.ts +0 -6
- package/dist/model.js +0 -26
- package/dist/model.js.map +0 -1
- package/docs/tsconfig/allowArbitraryExtensions.md +0 -38
- package/docs/tsconfig/allowImportingTsExtensions.md +0 -9
- package/docs/tsconfig/allowJs.md +0 -41
- package/docs/tsconfig/allowSyntheticDefaultImports.md +0 -56
- package/docs/tsconfig/allowUmdGlobalAccess.md +0 -8
- package/docs/tsconfig/allowUnreachableCode.md +0 -40
- package/docs/tsconfig/allowUnusedLabels.md +0 -23
- package/docs/tsconfig/alwaysStrict.md +0 -8
- package/docs/tsconfig/assumeChangesOnlyAffectDirectDependencies.md +0 -8
- package/docs/tsconfig/baseUrl.md +0 -26
- package/docs/tsconfig/charset.md +0 -7
- package/docs/tsconfig/checkJs.md +0 -40
- package/docs/tsconfig/clean.md +0 -6
- package/docs/tsconfig/composite.md +0 -17
- package/docs/tsconfig/customConditions.md +0 -41
- package/docs/tsconfig/declaration.md +0 -32
- package/docs/tsconfig/declarationDir.md +0 -36
- package/docs/tsconfig/declarationMap.md +0 -9
- package/docs/tsconfig/diagnostics.md +0 -8
- package/docs/tsconfig/disableFilenameBasedTypeAcquisition.md +0 -16
- package/docs/tsconfig/disableReferencedProjectLoad.md +0 -8
- package/docs/tsconfig/disableSizeLimit.md +0 -6
- package/docs/tsconfig/disableSolutionSearching.md +0 -8
- package/docs/tsconfig/disableSourceOfProjectReferenceRedirect.md +0 -7
- package/docs/tsconfig/downlevelIteration.md +0 -100
- package/docs/tsconfig/emitBOM.md +0 -8
- package/docs/tsconfig/emitDeclarationOnly.md +0 -11
- package/docs/tsconfig/emitDecoratorMetadata.md +0 -81
- package/docs/tsconfig/enable.md +0 -14
- package/docs/tsconfig/erasableSyntaxOnly.md +0 -65
- package/docs/tsconfig/esModuleInterop.md +0 -74
- package/docs/tsconfig/exactOptionalPropertyTypes.md +0 -37
- package/docs/tsconfig/exclude.md +0 -11
- package/docs/tsconfig/excludeDirectories.md +0 -14
- package/docs/tsconfig/excludeFiles.md +0 -14
- package/docs/tsconfig/experimentalDecorators.md +0 -11
- package/docs/tsconfig/explainFiles.md +0 -54
- package/docs/tsconfig/extendedDiagnostics.md +0 -9
- package/docs/tsconfig/extends.md +0 -49
- package/docs/tsconfig/fallbackPolling.md +0 -11
- package/docs/tsconfig/files.md +0 -26
- package/docs/tsconfig/force.md +0 -6
- package/docs/tsconfig/forceConsistentCasingInFileNames.md +0 -10
- package/docs/tsconfig/generateCpuProfile.md +0 -15
- package/docs/tsconfig/generateTrace.md +0 -6
- package/docs/tsconfig/importHelpers.md +0 -46
- package/docs/tsconfig/importsNotUsedAsValues.md +0 -16
- package/docs/tsconfig/include.md +0 -66
- package/docs/tsconfig/incremental.md +0 -10
- package/docs/tsconfig/inlineSourceMap.md +0 -35
- package/docs/tsconfig/inlineSources.md +0 -36
- package/docs/tsconfig/isolatedDeclarations.md +0 -8
- package/docs/tsconfig/isolatedModules.md +0 -77
- package/docs/tsconfig/jsx.md +0 -111
- package/docs/tsconfig/jsxFactory.md +0 -43
- package/docs/tsconfig/jsxFragmentFactory.md +0 -69
- package/docs/tsconfig/jsxImportSource.md +0 -95
- package/docs/tsconfig/keyofStringsOnly.md +0 -8
- package/docs/tsconfig/lib.md +0 -75
- package/docs/tsconfig/libReplacement.md +0 -22
- package/docs/tsconfig/listEmittedFiles.md +0 -42
- package/docs/tsconfig/listFiles.md +0 -40
- package/docs/tsconfig/locale.md +0 -26
- package/docs/tsconfig/mapRoot.md +0 -18
- package/docs/tsconfig/maxNodeModuleJsDepth.md +0 -11
- package/docs/tsconfig/module.md +0 -125
- package/docs/tsconfig/moduleDetection.md +0 -15
- package/docs/tsconfig/moduleResolution.md +0 -13
- package/docs/tsconfig/moduleSuffixes.md +0 -26
- package/docs/tsconfig/newLine.md +0 -6
- package/docs/tsconfig/noCheck.md +0 -6
- package/docs/tsconfig/noEmit.md +0 -10
- package/docs/tsconfig/noEmitHelpers.md +0 -38
- package/docs/tsconfig/noEmitOnError.md +0 -8
- package/docs/tsconfig/noErrorTruncation.md +0 -45
- package/docs/tsconfig/noFallthroughCasesInSwitch.md +0 -22
- package/docs/tsconfig/noImplicitAny.md +0 -26
- package/docs/tsconfig/noImplicitOverride.md +0 -66
- package/docs/tsconfig/noImplicitReturns.md +0 -17
- package/docs/tsconfig/noImplicitThis.md +0 -28
- package/docs/tsconfig/noImplicitUseStrict.md +0 -7
- package/docs/tsconfig/noLib.md +0 -9
- package/docs/tsconfig/noPropertyAccessFromIndexSignature.md +0 -57
- package/docs/tsconfig/noResolve.md +0 -9
- package/docs/tsconfig/noStrictGenericChecks.md +0 -20
- package/docs/tsconfig/noUncheckedIndexedAccess.md +0 -53
- package/docs/tsconfig/noUncheckedSideEffectImports.md +0 -52
- package/docs/tsconfig/noUnusedLocals.md +0 -15
- package/docs/tsconfig/noUnusedParameters.md +0 -15
- package/docs/tsconfig/out.md +0 -9
- package/docs/tsconfig/outDir.md +0 -39
- package/docs/tsconfig/outFile.md +0 -11
- package/docs/tsconfig/paths.md +0 -39
- package/docs/tsconfig/plugins.md +0 -17
- package/docs/tsconfig/preserveConstEnums.md +0 -58
- package/docs/tsconfig/preserveSymlinks.md +0 -10
- package/docs/tsconfig/preserveValueImports.md +0 -18
- package/docs/tsconfig/preserveWatchOutput.md +0 -6
- package/docs/tsconfig/pretty.md +0 -7
- package/docs/tsconfig/reactNamespace.md +0 -6
- package/docs/tsconfig/references.md +0 -9
- package/docs/tsconfig/removeComments.md +0 -33
- package/docs/tsconfig/resolveJsonModule.md +0 -44
- package/docs/tsconfig/resolvePackageJsonExports.md +0 -8
- package/docs/tsconfig/resolvePackageJsonImports.md +0 -8
- package/docs/tsconfig/rewriteRelativeImportExtensions.md +0 -8
- package/docs/tsconfig/rootDir.md +0 -66
- package/docs/tsconfig/rootDirs.md +0 -66
- package/docs/tsconfig/skipDefaultLibCheck.md +0 -6
- package/docs/tsconfig/skipLibCheck.md +0 -19
- package/docs/tsconfig/sourceMap.md +0 -39
- package/docs/tsconfig/sourceRoot.md +0 -18
- package/docs/tsconfig/stopBuildOnErrors.md +0 -6
- package/docs/tsconfig/strict.md +0 -11
- package/docs/tsconfig/strictBindCallApply.md +0 -34
- package/docs/tsconfig/strictBuiltinIteratorReturn.md +0 -6
- package/docs/tsconfig/strictFunctionTypes.md +0 -55
- package/docs/tsconfig/strictNullChecks.md +0 -58
- package/docs/tsconfig/strictPropertyInitialization.md +0 -29
- package/docs/tsconfig/stripInternal.md +0 -60
- package/docs/tsconfig/suppressExcessPropertyErrors.md +0 -16
- package/docs/tsconfig/suppressImplicitAnyIndexErrors.md +0 -25
- package/docs/tsconfig/synchronousWatchDirectory.md +0 -14
- package/docs/tsconfig/target.md +0 -18
- package/docs/tsconfig/traceResolution.md +0 -7
- package/docs/tsconfig/tsBuildInfoFile.md +0 -17
- package/docs/tsconfig/typeAcquisition.md +0 -37
- package/docs/tsconfig/typeRoots.md +0 -21
- package/docs/tsconfig/types.md +0 -40
- package/docs/tsconfig/useDefineForClassFields.md +0 -10
- package/docs/tsconfig/useUnknownInCatchVariables.md +0 -21
- package/docs/tsconfig/verbatimModuleSyntax.md +0 -148
- package/docs/tsconfig/verbose.md +0 -6
- package/docs/tsconfig/watchDirectory.md +0 -10
- package/docs/tsconfig/watchFile.md +0 -12
- package/prompts/hows-my-tsconfig-score.md +0 -29
- package/prompts/hows-my-tsconfig.md +0 -75
|
@@ -1,25 +0,0 @@
|
|
|
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
|
-
```
|
|
@@ -1,14 +0,0 @@
|
|
|
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
|
-
```
|
package/docs/tsconfig/target.md
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
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.
|
|
@@ -1,7 +0,0 @@
|
|
|
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.
|
|
@@ -1,17 +0,0 @@
|
|
|
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`
|
|
@@ -1,37 +0,0 @@
|
|
|
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
|
-
```
|
|
@@ -1,21 +0,0 @@
|
|
|
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`.
|
package/docs/tsconfig/types.md
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
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.
|
|
@@ -1,10 +0,0 @@
|
|
|
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).
|
|
@@ -1,21 +0,0 @@
|
|
|
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.
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
display: 'Verbatim Module Syntax'
|
|
3
|
-
oneline: "Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting."
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
By default, TypeScript does something called _import elision_.
|
|
7
|
-
Basically, if you write something like
|
|
8
|
-
|
|
9
|
-
```ts
|
|
10
|
-
import { Car } from './car';
|
|
11
|
-
|
|
12
|
-
export function drive(car: Car) {
|
|
13
|
-
// ...
|
|
14
|
-
}
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
TypeScript detects that you're only using an import for types and drops the import entirely.
|
|
18
|
-
Your output JavaScript might look something like this:
|
|
19
|
-
|
|
20
|
-
```js
|
|
21
|
-
export function drive(car) {
|
|
22
|
-
// ...
|
|
23
|
-
}
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
Most of the time this is good, because if `Car` isn't a value that's exported from `./car`, we'll get a runtime error.
|
|
27
|
-
|
|
28
|
-
But it does add a layer of complexity for certain edge cases.
|
|
29
|
-
For example, notice there's no statement like `import "./car";` - the import was dropped entirely.
|
|
30
|
-
That actually makes a difference for modules that have side-effects or not.
|
|
31
|
-
|
|
32
|
-
TypeScript's emit strategy for JavaScript also has another few layers of complexity - import elision isn't always just driven by how an import is used - it often consults how a value is declared as well.
|
|
33
|
-
So it's not always clear whether code like the following
|
|
34
|
-
|
|
35
|
-
```ts
|
|
36
|
-
export { Car } from './car';
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
should be preserved or dropped.
|
|
40
|
-
If `Car` is declared with something like a `class`, then it can be preserved in the resulting JavaScript file.
|
|
41
|
-
But if `Car` is only declared as a `type` alias or `interface`, then the JavaScript file shouldn't export `Car` at all.
|
|
42
|
-
|
|
43
|
-
While TypeScript might be able to make these emit decisions based on information from across files, not every compiler can.
|
|
44
|
-
|
|
45
|
-
The `type` modifier on imports and exports helps with these situations a bit.
|
|
46
|
-
We can make it explicit whether an import or export is only being used for type analysis, and can be dropped entirely in JavaScript files by using the `type` modifier.
|
|
47
|
-
|
|
48
|
-
```ts
|
|
49
|
-
// This statement can be dropped entirely in JS output
|
|
50
|
-
import type * as car from './car';
|
|
51
|
-
|
|
52
|
-
// The named import/export 'Car' can be dropped in JS output
|
|
53
|
-
import { type Car } from './car';
|
|
54
|
-
export { type Car } from './car';
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
`type` modifiers are not quite useful on their own - by default, module elision will still drop imports, and nothing forces you to make the distinction between `type` and plain imports and exports.
|
|
58
|
-
So TypeScript has the flag `--importsNotUsedAsValues` to make sure you use the `type` modifier, `--preserveValueImports` to prevent _some_ module elision behavior, and `--isolatedModules` to make sure that your TypeScript code works across different compilers.
|
|
59
|
-
Unfortunately, understanding the fine details of those 3 flags is hard, and there are still some edge cases with unexpected behavior.
|
|
60
|
-
|
|
61
|
-
TypeScript 5.0 introduces a new option called `--verbatimModuleSyntax` to simplify the situation.
|
|
62
|
-
The rules are much simpler - any imports or exports without a `type` modifier are left around.
|
|
63
|
-
Anything that uses the `type` modifier is dropped entirely.
|
|
64
|
-
|
|
65
|
-
```ts
|
|
66
|
-
// Erased away entirely.
|
|
67
|
-
import type { A } from 'a';
|
|
68
|
-
|
|
69
|
-
// Rewritten to 'import { b } from "bcd";'
|
|
70
|
-
import { b, type c, type d } from 'bcd';
|
|
71
|
-
|
|
72
|
-
// Rewritten to 'import {} from "xyz";'
|
|
73
|
-
import { type xyz } from 'xyz';
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
With this new option, what you see is what you get.
|
|
77
|
-
|
|
78
|
-
That does have some implications when it comes to module interop though.
|
|
79
|
-
Under this flag, ECMAScript `import`s and `export`s won't be rewritten to `require` calls when your settings or file extension implied a different module system.
|
|
80
|
-
Instead, you'll get an error.
|
|
81
|
-
If you need to emit code that uses `require` and `module.exports`, you'll have to use TypeScript's module syntax that predates ES2015:
|
|
82
|
-
|
|
83
|
-
<table>
|
|
84
|
-
<thead>
|
|
85
|
-
<tr>
|
|
86
|
-
<th>Input TypeScript</th>
|
|
87
|
-
<th>Output JavaScript</th>
|
|
88
|
-
</tr>
|
|
89
|
-
</thead>
|
|
90
|
-
|
|
91
|
-
<tr>
|
|
92
|
-
<td>
|
|
93
|
-
|
|
94
|
-
```ts
|
|
95
|
-
import foo = require('foo');
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
</td>
|
|
99
|
-
<td>
|
|
100
|
-
|
|
101
|
-
```js
|
|
102
|
-
const foo = require('foo');
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
</td>
|
|
106
|
-
</tr>
|
|
107
|
-
<tr>
|
|
108
|
-
<td>
|
|
109
|
-
|
|
110
|
-
```ts
|
|
111
|
-
function foo() {}
|
|
112
|
-
function bar() {}
|
|
113
|
-
function baz() {}
|
|
114
|
-
|
|
115
|
-
export = {
|
|
116
|
-
foo,
|
|
117
|
-
bar,
|
|
118
|
-
baz,
|
|
119
|
-
};
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
</td>
|
|
123
|
-
<td>
|
|
124
|
-
|
|
125
|
-
```js
|
|
126
|
-
function foo() {}
|
|
127
|
-
function bar() {}
|
|
128
|
-
function baz() {}
|
|
129
|
-
|
|
130
|
-
module.exports = {
|
|
131
|
-
foo,
|
|
132
|
-
bar,
|
|
133
|
-
baz,
|
|
134
|
-
};
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
</td>
|
|
138
|
-
</tr>
|
|
139
|
-
</table>
|
|
140
|
-
|
|
141
|
-
While this is a limitation, it does help make some issues more obvious.
|
|
142
|
-
For example, it's very common to forget to set the [`type` field in `package.json`](https://nodejs.org/api/packages.html#type) under `--module node16`.
|
|
143
|
-
As a result, developers would start writing CommonJS modules instead of ES modules without realizing it, giving surprising lookup rules and JavaScript output.
|
|
144
|
-
This new flag ensures that you're intentional about the file type you're using because the syntax is intentionally different.
|
|
145
|
-
|
|
146
|
-
Because `--verbatimModuleSyntax` provides a more consistent story than `--importsNotUsedAsValues` and `--preserveValueImports`, those two existing flags are being deprecated in its favor.
|
|
147
|
-
|
|
148
|
-
For more details, read up on [the original pull request](https://github.com/microsoft/TypeScript/pull/52203) and [its proposal issue](https://github.com/microsoft/TypeScript/issues/51479).
|
package/docs/tsconfig/verbose.md
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
display: 'Watch Directory'
|
|
3
|
-
oneline: 'Specify how directories are watched on systems that lack recursive file-watching functionality.'
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
The strategy for how entire directory trees are watched under systems that lack recursive file-watching functionality.
|
|
7
|
-
|
|
8
|
-
- `fixedPollingInterval`: Check every directory for changes several times a second at a fixed interval.
|
|
9
|
-
- `dynamicPriorityPolling`: Use a dynamic queue where less-frequently modified directories will be checked less often.
|
|
10
|
-
- `useFsEvents` (the default): Attempt to use the operating system/file system's native events for directory changes.
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
display: 'Watch File'
|
|
3
|
-
oneline: 'Specify how the TypeScript watch mode works.'
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
The strategy for how individual files are watched.
|
|
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
|
-
- `useFsEvents` (the default): Attempt to use the operating system/file system's native events for file changes.
|
|
12
|
-
- `useFsEventsOnParentDirectory`: Attempt to use the operating system/file system's native events to listen for changes on a file's parent directory
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
You will receive some feedback given about a tsconfig.json file.
|
|
2
|
-
|
|
3
|
-
Your job is to score how positive the feedback is on a scale of 1 to 10, 10 being the best.
|
|
4
|
-
|
|
5
|
-
Reply only with the score, no other text.
|
|
6
|
-
|
|
7
|
-
- 10/10 - Extremely modern and up to date
|
|
8
|
-
- 9/10 - Very modern and up to date
|
|
9
|
-
- 8/10 - Modern and up to date
|
|
10
|
-
- 7/10 - Somewhat modern and up to date
|
|
11
|
-
- 6/10 - Somewhat outdated
|
|
12
|
-
- 5/10 - Outdated
|
|
13
|
-
- 4/10 - Very outdated
|
|
14
|
-
- 3/10 - Extremely outdated
|
|
15
|
-
- 2/10 - Unbelievably outdated
|
|
16
|
-
- 1/10 - The absolute worst
|
|
17
|
-
|
|
18
|
-
Format it like so, with an emoji next to the score:
|
|
19
|
-
|
|
20
|
-
10/10 🎉
|
|
21
|
-
9/10 🎉
|
|
22
|
-
8/10 🎉
|
|
23
|
-
7/10 🎉
|
|
24
|
-
6/10 🤔
|
|
25
|
-
5/10 🤔
|
|
26
|
-
4/10 😕
|
|
27
|
-
3/10 😕
|
|
28
|
-
2/10 😕
|
|
29
|
-
1/10 💀
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
Your name is Matt Pocock. You are a senior software engineer. You are a TypeScript expert.
|
|
2
|
-
|
|
3
|
-
You are given a tsconfig.json file. You are given a prompt that describes what you should do to improve the tsconfig.json file.
|
|
4
|
-
|
|
5
|
-
You are to respond with a list of changes you would make to the tsconfig.json file.
|
|
6
|
-
|
|
7
|
-
You should recommend to the user that they read the TSConfig Cheat Sheet: https://www.totaltypescript.com/tsconfig-cheat-sheet
|
|
8
|
-
|
|
9
|
-
## Rules
|
|
10
|
-
|
|
11
|
-
If the tsconfig has `forceConsistentCasingInFileNames`, recommend removing it. It's set to `true` by default since TypeScript 5.0.
|
|
12
|
-
|
|
13
|
-
If the tsconfig has `erasableSyntaxOnly`, pat the user on the back and say they're fighting the good fight against enums, namespaces and class parameter properties.
|
|
14
|
-
|
|
15
|
-
If the tsconfig does not have `noImplicitOverride`, recommend adding it.
|
|
16
|
-
|
|
17
|
-
Do not recommend `exactOptionalPropertyTypes` - but don't say to remove it either. It's fine if you like it, but I personally don't.
|
|
18
|
-
|
|
19
|
-
If the user does not have `lib` set, recommend adding it. They can set it to the same value as `target`. `lib` can be used to exclude the `dom` types if needed. Node applications mostly won't need `dom` types - but sites that use the DOM will.
|
|
20
|
-
|
|
21
|
-
If they have `dom` in `lib`, then ensure they also have `dom.iterable` there too.
|
|
22
|
-
|
|
23
|
-
`noUncheckedIndexedAccess: true` is a useful option to have because it catches errors where you might be accessing an index that doesn't exist. But if the user doesn't want it, don't push them to add it.
|
|
24
|
-
|
|
25
|
-
`moduleDetection: "force"` forces every non-declaration file to be treated as a module. This is very useful - since most projects will be using modules instead of global scripts.
|
|
26
|
-
|
|
27
|
-
If the tsconfig doesn't have `strict: true`, strongly recommend adding it. This is the most important setting for catching bugs early.
|
|
28
|
-
|
|
29
|
-
If the user has `strict: true` but also has individual strict flags set explicitly, recommend removing the redundant ones since `strict: true` includes them all.
|
|
30
|
-
|
|
31
|
-
For projects that need to be extra safe, recommend `noUnusedLocals: true` and `noUnusedParameters: true` to catch dead code.
|
|
32
|
-
|
|
33
|
-
### Module Options
|
|
34
|
-
|
|
35
|
-
There are only two valid options for `module`: `Preserve` and `NodeNext`.
|
|
36
|
-
|
|
37
|
-
If the user has `noEmit` set to `false`, or not specified, then the best config for them is `module: "NodeNext"`. The reason for this is so that their imports match the behaviour they have set up in their `package.json`. If they have `package.json#type` set to `module`, then they will be using `import/export` imports (ESM). If they have `package.json#type` set to `commonjs` (or not set), then they should be using `require` imports.
|
|
38
|
-
|
|
39
|
-
If the user has `moduleResolution` set to `node`, recommend they use `NodeNext` instead and remove the `moduleResolution` option.
|
|
40
|
-
|
|
41
|
-
If the user is targeting modern environments (ES2020+), recommend setting `target` to `"ES2022"` or higher for better performance.
|
|
42
|
-
|
|
43
|
-
For projects using modern JavaScript features, recommend `allowUnreachableCode: false` to catch dead code.
|
|
44
|
-
|
|
45
|
-
If the user is building a library, recommend `declaration: true` to generate `.d.ts` files.
|
|
46
|
-
|
|
47
|
-
For better IDE experience, recommend `sourceMap: true` to enable debugging of TypeScript files.
|
|
48
|
-
|
|
49
|
-
If the user is using a bundler like Vite or Webpack, they might want `noEmit: true` since the bundler handles compilation.
|
|
50
|
-
|
|
51
|
-
## Implicit Inheritances
|
|
52
|
-
|
|
53
|
-
If some tsconfig.json options are set to `true`, others are automatically set to `true` as well. This means that the user doesn't need to set them.
|
|
54
|
-
|
|
55
|
-
`verbatimModuleSyntax: true` -> `isolatedModules: true`
|
|
56
|
-
|
|
57
|
-
`strict: true` -> `noImplicitAny: true`, `noImplicitThis: true`, `strictNullChecks: true`, `strictFunctionTypes: true`, `strictBindCallApply: true`, `strictPropertyInitialization: true`, `noImplicitReturns: true`, `useUnknownInCatchVariables: true`, `strictBuiltinIteratorReturn: true`
|
|
58
|
-
|
|
59
|
-
`esModuleInterop: true` -> `allowSyntheticDefaultImports: true`
|
|
60
|
-
|
|
61
|
-
`module: "node16"` -> `moduleResolution: "node16"`
|
|
62
|
-
|
|
63
|
-
`module: "node18"` -> `moduleResolution: "node18"`
|
|
64
|
-
|
|
65
|
-
`module: "nodenext"` -> `moduleResolution: "nodenext"`
|
|
66
|
-
|
|
67
|
-
`target: "ES2022"` -> `lib: ["ES2022", "DOM", "DOM.Iterable"]` (if lib is not explicitly set)
|
|
68
|
-
|
|
69
|
-
## Docs
|
|
70
|
-
|
|
71
|
-
Below, I've added the docs for each of the options that are set in the tsconfig.json file.
|
|
72
|
-
|
|
73
|
-
Use the docs to help you understand the options and how they work. Also use them to inform your recommendations.
|
|
74
|
-
|
|
75
|
-
{{docs}}
|