@visulima/packem-rollup 1.0.0-alpha.22 → 1.0.0-alpha.24
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/CHANGELOG.md +25 -0
- package/LICENSE.md +0 -436
- package/dist/index.d.ts +25 -26
- package/dist/index.js +1 -0
- package/dist/packem_shared/cachingPlugin-CLawAGhx.js +1 -0
- package/dist/packem_shared/createSplitChunks-Ceq_Ca5Y.js +1 -0
- package/dist/packem_shared/{esbuildPlugin-BrFhdKJk.mjs → esbuildPlugin-DpLtQGuZ.js} +1 -1
- package/dist/packem_shared/oxcResolvePlugin-Ccef6pyL.js +1 -0
- package/dist/packem_shared/{patchTypescriptTypes-BEdkvKxL.mjs → patchTypescriptTypes-BX_sJsvd.js} +2 -2
- package/dist/packem_shared/{resolveTsconfigPathsPlugin-pUcTdE77.mjs → resolveTsconfigPathsPlugin-CEasmDpi.js} +1 -1
- package/dist/packem_shared/{resolveTsconfigRootDirectoriesPlugin-_93afm2q.mjs → resolveTsconfigRootDirectoriesPlugin-Cwj3tqCJ.js} +1 -1
- package/dist/packem_shared/{types-Bk7lLMcF.d.ts → types-BiZanzz1.d.ts} +25 -136
- package/dist/plugins/cjs-interop.d.ts +11 -0
- package/dist/{packem_shared/cjsInteropPlugin-D5wyoQ_B.mjs → plugins/cjs-interop.js} +1 -1
- package/dist/plugins/copy.d.ts +18 -0
- package/dist/plugins/copy.js +1 -0
- package/dist/plugins/data-uri.d.ts +12 -0
- package/dist/plugins/data-uri.js +1 -0
- package/dist/plugins/debarrel.d.ts +11 -0
- package/dist/{packem_shared/debarrelPlugin-BTYc859G.mjs → plugins/debarrel.js} +1 -1
- package/dist/plugins/esbuild/index.d.ts +19 -5
- package/dist/plugins/esbuild/index.js +1 -0
- package/dist/plugins/esm-shim-cjs-syntax.d.ts +13 -0
- package/dist/plugins/fix-dts-default-cjs-exports.d.ts +9 -0
- package/dist/plugins/fix-dts-default-cjs-exports.js +1 -0
- package/dist/plugins/isolated-declarations/index.d.ts +13 -0
- package/dist/{packem_shared/isolatedDeclarationsPlugin-B34s_qkE.mjs → plugins/isolated-declarations/index.js} +1 -1
- package/dist/plugins/json.d.ts +7 -0
- package/dist/plugins/json.js +1 -0
- package/dist/plugins/jsx-remove-attributes.d.ts +11 -0
- package/dist/plugins/jsx-remove-attributes.js +1 -0
- package/dist/plugins/license.d.ts +21 -0
- package/dist/plugins/license.js +13 -0
- package/dist/plugins/minify-html-literals/index.d.ts +96 -6
- package/dist/plugins/native-modules-plugin.d.ts +9 -0
- package/dist/plugins/oxc/index.d.ts +20 -6
- package/dist/plugins/oxc/index.js +1 -0
- package/dist/plugins/preserve-directives.d.ts +13 -0
- package/dist/{packem_shared/preserveDirectivesPlugin-B49Cbykd.mjs → plugins/preserve-directives.js} +3 -3
- package/dist/plugins/raw.d.ts +11 -0
- package/dist/plugins/require-cjs-transformer.d.ts +19 -0
- package/dist/plugins/require-cjs-transformer.js +25 -0
- package/dist/plugins/shebang.d.ts +13 -0
- package/dist/plugins/source-maps.d.ts +11 -0
- package/dist/plugins/sucrase/index.d.ts +18 -4
- package/dist/plugins/swc/index.d.ts +19 -5
- package/dist/plugins/swc/index.js +1 -0
- package/dist/plugins/typescript/index.d.ts +20 -6
- package/dist/plugins/typescript/index.js +1 -0
- package/dist/plugins/url.d.ts +17 -0
- package/dist/plugins/url.js +1 -0
- package/package.json +86 -18
- package/dist/index.d.mts +0 -59
- package/dist/index.mjs +0 -1
- package/dist/packem_shared/browserslist-to-esbuild-DY9HwYtp.d.mts +0 -3
- package/dist/packem_shared/cachingPlugin-TWoY5ZxV.mjs +0 -1
- package/dist/packem_shared/copyPlugin--6RITp1-.mjs +0 -1
- package/dist/packem_shared/createSplitChunks-CGDk55G3.mjs +0 -1
- package/dist/packem_shared/dataUriPlugin-BFb7bZZs.mjs +0 -1
- package/dist/packem_shared/fixDtsDefaultCjsExportsPlugin-Dp1UcHVR.mjs +0 -1
- package/dist/packem_shared/index-hWYvkB02.d.mts +0 -346
- package/dist/packem_shared/index-hWYvkB02.d.ts +0 -346
- package/dist/packem_shared/jsonPlugin-BAi3Da-h.mjs +0 -1
- package/dist/packem_shared/jsxRemoveAttributes-B1PLPffj.mjs +0 -1
- package/dist/packem_shared/licensePlugin-C5yzUqe-.mjs +0 -13
- package/dist/packem_shared/oxcResolvePlugin-BJpi-eSG.mjs +0 -1
- package/dist/packem_shared/requireCJSTransformerPlugin-qcY8AH5r.mjs +0 -26
- package/dist/packem_shared/types-CMThMMkh.d.mts +0 -4337
- package/dist/packem_shared/urlPlugin-DJJrDWjj.mjs +0 -1
- package/dist/plugins/esbuild/index.d.mts +0 -28
- package/dist/plugins/esbuild/index.mjs +0 -1
- package/dist/plugins/minify-html-literals/index.d.mts +0 -5
- package/dist/plugins/oxc/index.d.mts +0 -31
- package/dist/plugins/oxc/index.mjs +0 -1
- package/dist/plugins/sucrase/index.d.mts +0 -22
- package/dist/plugins/swc/index.d.mts +0 -29
- package/dist/plugins/swc/index.mjs +0 -1
- package/dist/plugins/typescript/index.d.mts +0 -32
- package/dist/plugins/typescript/index.mjs +0 -1
- /package/dist/packem_shared/{browserslistToEsbuild-C0IWmbNe.mjs → browserslistToEsbuild-C0IWmbNe.js} +0 -0
- /package/dist/packem_shared/{chunkSplitter-DWAy1JkE.mjs → chunkSplitter-DWAy1JkE.js} +0 -0
- /package/dist/packem_shared/{fix-dts-default-cjs-exports-BQc0nwIG.mjs → fix-dts-default-cjs-exports-BQc0nwIG.js} +0 -0
- /package/dist/packem_shared/{fixDynamicImportExtension-BBGNRniz.mjs → fixDynamicImportExtension-BBGNRniz.js} +0 -0
- /package/dist/packem_shared/{getCustomModuleLayer-d8i66lfh.mjs → getCustomModuleLayer-d8i66lfh.js} +0 -0
- /package/dist/packem_shared/{getModuleLayer-rF9RxnJ5.mjs → getModuleLayer-rF9RxnJ5.js} +0 -0
- /package/dist/packem_shared/{index-Dq8IUFTs.mjs → index-Dq8IUFTs.js} +0 -0
- /package/dist/packem_shared/{index-QEzU3Fey.mjs → index-QEzU3Fey.js} +0 -0
- /package/dist/packem_shared/{isolatedDeclarationsOxcTransformer-WbfE6cGu.mjs → isolatedDeclarationsOxcTransformer-WbfE6cGu.js} +0 -0
- /package/dist/packem_shared/{isolatedDeclarationsSwcTransformer-Ch2AgtWC.mjs → isolatedDeclarationsSwcTransformer-Ch2AgtWC.js} +0 -0
- /package/dist/packem_shared/{isolatedDeclarationsTypescriptTransformer-DkuEkofo.mjs → isolatedDeclarationsTypescriptTransformer-DkuEkofo.js} +0 -0
- /package/dist/packem_shared/{metafilePlugin-CVcqFpPJ.mjs → metafilePlugin-CVcqFpPJ.js} +0 -0
- /package/dist/packem_shared/{oxcTransformPlugin-DfVQouIB.mjs → oxcTransformPlugin-DfVQouIB.js} +0 -0
- /package/dist/packem_shared/{resolveFileUrlPlugin-BkpjVHeK.mjs → resolveFileUrlPlugin-BkpjVHeK.js} +0 -0
- /package/dist/packem_shared/{resolveTypescriptMjsCtsPlugin-DcZrZTmM.mjs → resolveTypescriptMjsCtsPlugin-DcZrZTmM.js} +0 -0
- /package/dist/packem_shared/{swcPlugin-Boip4lWG.mjs → swcPlugin-Boip4lWG.js} +0 -0
- /package/dist/{packem_shared/esmShimCjsSyntaxPlugin-DjKqX4DE.mjs → plugins/esm-shim-cjs-syntax.js} +0 -0
- /package/dist/plugins/minify-html-literals/{index.mjs → index.js} +0 -0
- /package/dist/{packem_shared/nativeModulesPlugin-D6lO-8g6.mjs → plugins/native-modules-plugin.js} +0 -0
- /package/dist/{packem_shared/rawPlugin-DgRj14Xy.mjs → plugins/raw.js} +0 -0
- /package/dist/{packem_shared/makeExecutable-6aOVHoJR.mjs → plugins/shebang.js} +0 -0
- /package/dist/{packem_shared/sourcemapsPlugin-B4W3J79w.mjs → plugins/source-maps.js} +0 -0
- /package/dist/plugins/sucrase/{index.mjs → index.js} +0 -0
|
@@ -1,4337 +0,0 @@
|
|
|
1
|
-
import { RollupAliasOptions } from '@rollup/plugin-alias';
|
|
2
|
-
import { RollupCommonJSOptions } from '@rollup/plugin-commonjs';
|
|
3
|
-
import { RollupJsonOptions } from '@rollup/plugin-json';
|
|
4
|
-
import { RollupNodeResolveOptions } from '@rollup/plugin-node-resolve';
|
|
5
|
-
import { RollupReplaceOptions } from '@rollup/plugin-replace';
|
|
6
|
-
import { RollupWasmOptions } from '@rollup/plugin-wasm';
|
|
7
|
-
import { FilterPattern } from '@rollup/pluginutils';
|
|
8
|
-
import { Plugin as Plugin$1, OutputOptions, RollupOptions } from 'rollup';
|
|
9
|
-
import { Options as Options$4 } from 'rollup-plugin-dts';
|
|
10
|
-
import { NodePolyfillsOptions } from 'rollup-plugin-polyfill-node';
|
|
11
|
-
import { PureAnnotationsOptions } from 'rollup-plugin-pure';
|
|
12
|
-
import { PluginVisualizerOptions } from 'rollup-plugin-visualizer';
|
|
13
|
-
import { P as PailServerType, M as MinifyHTMLLiteralsOptions } from './index-hWYvkB02.mjs';
|
|
14
|
-
import { TransformOptions, Loader, BuildOptions } from 'esbuild';
|
|
15
|
-
import { PackageJson } from '@visulima/package';
|
|
16
|
-
import { BuildContext } from '@visulima/packem-share/types';
|
|
17
|
-
import { NapiResolveOptions } from 'oxc-resolver';
|
|
18
|
-
import { TransformOptions as TransformOptions$1, JsxOptions } from 'oxc-transform';
|
|
19
|
-
import { Options as Options$3 } from 'sucrase';
|
|
20
|
-
|
|
21
|
-
interface CJSInteropOptions {
|
|
22
|
-
addDefaultProperty?: boolean;
|
|
23
|
-
}
|
|
24
|
-
declare const cjsInteropPlugin: ({ addDefaultProperty, logger, }: CJSInteropOptions & {
|
|
25
|
-
logger: PailServerType;
|
|
26
|
-
}) => Plugin$1;
|
|
27
|
-
|
|
28
|
-
type CopyPluginOptions = {
|
|
29
|
-
copyOnce?: boolean;
|
|
30
|
-
exactFileNames?: boolean;
|
|
31
|
-
flatten?: boolean;
|
|
32
|
-
targets: MultipleTargetsDesc;
|
|
33
|
-
};
|
|
34
|
-
type MultipleTargetsDesc = SingleTargetDesc | SingleTargetDesc[] | string[] | string;
|
|
35
|
-
type SingleTargetDesc = {
|
|
36
|
-
dest?: string;
|
|
37
|
-
exclude?: string[] | string;
|
|
38
|
-
src: string[] | string;
|
|
39
|
-
};
|
|
40
|
-
declare const copyPlugin: (options: CopyPluginOptions, logger: PailServerType) => Plugin$1;
|
|
41
|
-
|
|
42
|
-
type DataUriPluginOptions = {
|
|
43
|
-
exclude?: FilterPattern;
|
|
44
|
-
include?: FilterPattern;
|
|
45
|
-
srcset?: boolean;
|
|
46
|
-
};
|
|
47
|
-
declare const dataUriPlugin: (options?: DataUriPluginOptions) => Plugin$1;
|
|
48
|
-
|
|
49
|
-
interface DebarrelPluginOptions {
|
|
50
|
-
include?: FilterPattern;
|
|
51
|
-
possibleBarrelFiles?: (RegExp | string)[];
|
|
52
|
-
}
|
|
53
|
-
declare const debarrelPlugin: (options: DebarrelPluginOptions, logger: PailServerType) => Plugin$1;
|
|
54
|
-
|
|
55
|
-
interface EsmShimCjsSyntaxOptions {
|
|
56
|
-
exclude?: FilterPattern;
|
|
57
|
-
include?: FilterPattern;
|
|
58
|
-
}
|
|
59
|
-
declare const esmShimCjsSyntaxPlugin: (packageJson: PackageJson, options: EsmShimCjsSyntaxOptions) => Plugin$1;
|
|
60
|
-
|
|
61
|
-
type IsolatedDeclarationsOptions = {
|
|
62
|
-
exclude?: FilterPattern;
|
|
63
|
-
ignoreErrors?: boolean;
|
|
64
|
-
include?: FilterPattern;
|
|
65
|
-
};
|
|
66
|
-
declare const isolatedDeclarationsPlugin: <T extends Record<string, any>>(sourceDirectory: string, context: BuildContext<T>) => Plugin$1;
|
|
67
|
-
|
|
68
|
-
type JSXRemoveAttributesPlugin = {
|
|
69
|
-
attributes: string[];
|
|
70
|
-
};
|
|
71
|
-
declare const jsxRemoveAttributes: ({ attributes, logger }: JSXRemoveAttributesPlugin & {
|
|
72
|
-
logger: PailServerType;
|
|
73
|
-
}) => Plugin$1;
|
|
74
|
-
|
|
75
|
-
interface LicenseOptions {
|
|
76
|
-
dependenciesMarker?: string;
|
|
77
|
-
dependenciesTemplate?: (licenses: string[], dependencyLicenseTexts: string, packageName: string | undefined) => string;
|
|
78
|
-
dtsMarker?: string;
|
|
79
|
-
dtsTemplate?: (licenses: string[], dependencyLicenseTexts: string, packageName: string | undefined) => string;
|
|
80
|
-
path?: string;
|
|
81
|
-
}
|
|
82
|
-
declare const license: ({ dtsMarker, licenseFilePath, licenseTemplate, logger, marker, mode, packageName, }: {
|
|
83
|
-
dtsMarker?: string;
|
|
84
|
-
licenseFilePath: string;
|
|
85
|
-
licenseTemplate: (licenses: string[], dependencyLicenseTexts: string, packageName: string | undefined) => string;
|
|
86
|
-
logger: PailServerType;
|
|
87
|
-
marker: string;
|
|
88
|
-
mode: "dependencies" | "types";
|
|
89
|
-
packageName: string | undefined;
|
|
90
|
-
}) => Plugin$1;
|
|
91
|
-
|
|
92
|
-
interface NativeModulesOptions {
|
|
93
|
-
nativesDirectory?: string;
|
|
94
|
-
}
|
|
95
|
-
declare const nativeModulesPlugin: (config?: NativeModulesOptions) => Plugin$1;
|
|
96
|
-
|
|
97
|
-
interface RawLoaderOptions {
|
|
98
|
-
exclude?: FilterPattern;
|
|
99
|
-
include?: FilterPattern;
|
|
100
|
-
}
|
|
101
|
-
declare const rawPlugin: (options: RawLoaderOptions) => Plugin$1;
|
|
102
|
-
|
|
103
|
-
type Awaitable<T> = T | Promise<T>;
|
|
104
|
-
type TransformFunction = (id: string, importer: string, rollupResolve: (id: string, importer?: string) => Promise<{
|
|
105
|
-
id: string;
|
|
106
|
-
}>) => Awaitable<boolean | undefined | void>;
|
|
107
|
-
interface Options$2 {
|
|
108
|
-
builtinNodeModules?: boolean;
|
|
109
|
-
cwd?: string;
|
|
110
|
-
exclude?: FilterPattern;
|
|
111
|
-
include?: FilterPattern;
|
|
112
|
-
order?: "pre" | "post" | undefined;
|
|
113
|
-
shouldTransform?: string[] | TransformFunction;
|
|
114
|
-
}
|
|
115
|
-
declare const requireCJSTransformerPlugin: (userOptions: Options$2, logger: PailServerType) => Plugin$1;
|
|
116
|
-
|
|
117
|
-
type ShebangOptions = {
|
|
118
|
-
replace: boolean;
|
|
119
|
-
shebang: string;
|
|
120
|
-
};
|
|
121
|
-
declare const makeExecutable: (filePath: string) => Promise<void>;
|
|
122
|
-
declare const shebangPlugin: (executablePaths: string[], options: ShebangOptions) => Plugin$1;
|
|
123
|
-
declare const removeShebangPlugin: () => Plugin$1;
|
|
124
|
-
declare const getShebang: (code: string, append?: string) => string;
|
|
125
|
-
|
|
126
|
-
interface SourcemapsPluginOptions {
|
|
127
|
-
exclude?: FilterPattern;
|
|
128
|
-
include?: FilterPattern;
|
|
129
|
-
}
|
|
130
|
-
declare const sourcemapsPlugin: ({ exclude, include }?: SourcemapsPluginOptions) => Plugin$1;
|
|
131
|
-
|
|
132
|
-
interface UrlOptions {
|
|
133
|
-
destDir?: string;
|
|
134
|
-
emitFiles: boolean;
|
|
135
|
-
exclude?: FilterPattern;
|
|
136
|
-
fileName: string;
|
|
137
|
-
include?: FilterPattern;
|
|
138
|
-
limit: number;
|
|
139
|
-
publicPath?: string;
|
|
140
|
-
sourceDir?: string;
|
|
141
|
-
}
|
|
142
|
-
declare const urlPlugin: ({ destDir: destinationDirectory, emitFiles, exclude, fileName, include, limit, publicPath, sourceDir: sourceDirectory, }: UrlOptions) => Plugin$1;
|
|
143
|
-
|
|
144
|
-
type MarkOptional<Type, Keys extends keyof Type> = Type extends Type ? Omit<Type, Keys> & Partial<Pick<Type, Keys>> : never;
|
|
145
|
-
type EsbuildPluginConfig = Options$1 & {
|
|
146
|
-
logger: PailServerType;
|
|
147
|
-
};
|
|
148
|
-
type Optimized = Map<string, {
|
|
149
|
-
file: string;
|
|
150
|
-
}>;
|
|
151
|
-
type OptimizeDepsOptions = {
|
|
152
|
-
cwd: string;
|
|
153
|
-
esbuildOptions?: BuildOptions;
|
|
154
|
-
exclude?: string[];
|
|
155
|
-
include: string[];
|
|
156
|
-
sourceMap: boolean;
|
|
157
|
-
};
|
|
158
|
-
type OptimizeDepsResult = {
|
|
159
|
-
cacheDir: string;
|
|
160
|
-
optimized: Optimized;
|
|
161
|
-
};
|
|
162
|
-
type Options$1 = Omit<TransformOptions, "loader" | "sourcemap"> & {
|
|
163
|
-
exclude?: FilterPattern;
|
|
164
|
-
include?: FilterPattern;
|
|
165
|
-
loaders?: Record<string, Loader | false>;
|
|
166
|
-
optimizeDeps?: MarkOptional<OptimizeDepsOptions, "cwd" | "sourceMap">;
|
|
167
|
-
sourceMap?: boolean;
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
type InternalOXCTransformPluginConfig = TransformOptions$1 & {
|
|
171
|
-
exclude?: FilterPattern;
|
|
172
|
-
include?: FilterPattern;
|
|
173
|
-
};
|
|
174
|
-
type OXCTransformPluginConfig = Omit<TransformOptions$1, "cwd" | "sourcemap" | "target" | "typescript"> & {
|
|
175
|
-
exclude?: FilterPattern;
|
|
176
|
-
include?: FilterPattern;
|
|
177
|
-
jsx?: Omit<JsxOptions, "refresh"> | "preserve";
|
|
178
|
-
};
|
|
179
|
-
type OxcResolveOptions = Omit<NapiResolveOptions, "tsconfig"> & {
|
|
180
|
-
ignoreSideEffectsForRoot?: boolean;
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
interface SucrasePluginConfig extends Options$3 {
|
|
184
|
-
exclude?: FilterPattern;
|
|
185
|
-
include?: FilterPattern;
|
|
186
|
-
}
|
|
187
|
-
declare const sucrasePlugin: TransformerFn;
|
|
188
|
-
|
|
189
|
-
interface Assumptions {
|
|
190
|
-
/**
|
|
191
|
-
* https://babeljs.io/docs/en/assumptions#arraylikeisiterable
|
|
192
|
-
*/
|
|
193
|
-
arrayLikeIsIterable?: boolean;
|
|
194
|
-
/**
|
|
195
|
-
* https://babeljs.io/docs/en/assumptions#constantreexports
|
|
196
|
-
*/
|
|
197
|
-
constantReexports?: boolean;
|
|
198
|
-
/**
|
|
199
|
-
* https://babeljs.io/docs/en/assumptions#constantsuper
|
|
200
|
-
*/
|
|
201
|
-
constantSuper?: boolean;
|
|
202
|
-
/**
|
|
203
|
-
* https://babeljs.io/docs/en/assumptions#enumerablemodulemeta
|
|
204
|
-
*/
|
|
205
|
-
enumerableModuleMeta?: boolean;
|
|
206
|
-
/**
|
|
207
|
-
* https://babeljs.io/docs/en/assumptions#ignorefunctionlength
|
|
208
|
-
*/
|
|
209
|
-
ignoreFunctionLength?: boolean;
|
|
210
|
-
ignoreFunctionName?: boolean;
|
|
211
|
-
/**
|
|
212
|
-
* https://babeljs.io/docs/en/assumptions#ignoretoprimitivehint
|
|
213
|
-
*/
|
|
214
|
-
ignoreToPrimitiveHint?: boolean;
|
|
215
|
-
/**
|
|
216
|
-
* https://babeljs.io/docs/en/assumptions#iterableisarray
|
|
217
|
-
*/
|
|
218
|
-
iterableIsArray?: boolean;
|
|
219
|
-
/**
|
|
220
|
-
* https://babeljs.io/docs/en/assumptions#mutabletemplateobject
|
|
221
|
-
*/
|
|
222
|
-
mutableTemplateObject?: boolean;
|
|
223
|
-
/**
|
|
224
|
-
* https://babeljs.io/docs/en/assumptions#noclasscalls
|
|
225
|
-
*/
|
|
226
|
-
noClassCalls?: boolean;
|
|
227
|
-
/**
|
|
228
|
-
* https://babeljs.io/docs/en/assumptions#nodocumentall
|
|
229
|
-
*/
|
|
230
|
-
noDocumentAll?: boolean;
|
|
231
|
-
/**
|
|
232
|
-
* https://babeljs.io/docs/en/assumptions#noincompletensimportdetection
|
|
233
|
-
*/
|
|
234
|
-
noIncompleteNsImportDetection?: boolean;
|
|
235
|
-
/**
|
|
236
|
-
* https://babeljs.io/docs/en/assumptions#nonewarrows
|
|
237
|
-
*/
|
|
238
|
-
noNewArrows?: boolean;
|
|
239
|
-
/**
|
|
240
|
-
* https://babeljs.io/docs/en/assumptions#objectrestnosymbols
|
|
241
|
-
*/
|
|
242
|
-
objectRestNoSymbols?: boolean;
|
|
243
|
-
/**
|
|
244
|
-
* https://babeljs.io/docs/en/assumptions#privatefieldsasproperties
|
|
245
|
-
*/
|
|
246
|
-
privateFieldsAsProperties?: boolean;
|
|
247
|
-
/**
|
|
248
|
-
* https://babeljs.io/docs/en/assumptions#puregetters
|
|
249
|
-
*/
|
|
250
|
-
pureGetters?: boolean;
|
|
251
|
-
/**
|
|
252
|
-
* https://babeljs.io/docs/en/assumptions#setclassmethods
|
|
253
|
-
*/
|
|
254
|
-
setClassMethods?: boolean;
|
|
255
|
-
/**
|
|
256
|
-
* https://babeljs.io/docs/en/assumptions#setcomputedproperties
|
|
257
|
-
*/
|
|
258
|
-
setComputedProperties?: boolean;
|
|
259
|
-
/**
|
|
260
|
-
* https://babeljs.io/docs/en/assumptions#setpublicclassfields
|
|
261
|
-
*/
|
|
262
|
-
setPublicClassFields?: boolean;
|
|
263
|
-
/**
|
|
264
|
-
* https://babeljs.io/docs/en/assumptions#setspreadproperties
|
|
265
|
-
*/
|
|
266
|
-
setSpreadProperties?: boolean;
|
|
267
|
-
/**
|
|
268
|
-
* https://babeljs.io/docs/en/assumptions#skipforofiteratorclosing
|
|
269
|
-
*/
|
|
270
|
-
skipForOfIteratorClosing?: boolean;
|
|
271
|
-
/**
|
|
272
|
-
* https://babeljs.io/docs/en/assumptions#superiscallableconstructor
|
|
273
|
-
*/
|
|
274
|
-
superIsCallableConstructor?: boolean;
|
|
275
|
-
/**
|
|
276
|
-
* @deprecated This value will be always true
|
|
277
|
-
*/
|
|
278
|
-
tsEnumIsReadonly?: boolean;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
interface Plugin {
|
|
282
|
-
(module: Program): Program;
|
|
283
|
-
}
|
|
284
|
-
type TerserEcmaVersion = 5 | 2015 | 2016 | string | number;
|
|
285
|
-
interface JsMinifyOptions {
|
|
286
|
-
compress?: TerserCompressOptions | boolean;
|
|
287
|
-
format?: JsFormatOptions & ToSnakeCaseProperties<JsFormatOptions>;
|
|
288
|
-
mangle?: TerserMangleOptions | boolean;
|
|
289
|
-
ecma?: TerserEcmaVersion;
|
|
290
|
-
keep_classnames?: boolean;
|
|
291
|
-
keep_fnames?: boolean;
|
|
292
|
-
module?: boolean | "unknown";
|
|
293
|
-
safari10?: boolean;
|
|
294
|
-
toplevel?: boolean;
|
|
295
|
-
sourceMap?: boolean;
|
|
296
|
-
outputPath?: string;
|
|
297
|
-
inlineSourcesContent?: boolean;
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* @example ToSnakeCase<'indentLevel'> == 'indent_level'
|
|
301
|
-
*/
|
|
302
|
-
type ToSnakeCase<T extends string> = T extends `${infer A}${infer B}` ? `${A extends Lowercase<A> ? A : `_${Lowercase<A>}`}${ToSnakeCase<B>}` : T;
|
|
303
|
-
/**
|
|
304
|
-
* @example ToSnakeCaseProperties<{indentLevel: 3}> == {indent_level: 3}
|
|
305
|
-
*/
|
|
306
|
-
type ToSnakeCaseProperties<T> = {
|
|
307
|
-
[K in keyof T as K extends string ? ToSnakeCase<K> : K]: T[K];
|
|
308
|
-
};
|
|
309
|
-
/**
|
|
310
|
-
* These properties are mostly not implemented yet,
|
|
311
|
-
* but it exists to support passing terser config to swc minify
|
|
312
|
-
* without modification.
|
|
313
|
-
*/
|
|
314
|
-
interface JsFormatOptions {
|
|
315
|
-
/**
|
|
316
|
-
* Currently noop.
|
|
317
|
-
* @default false
|
|
318
|
-
* @alias ascii_only
|
|
319
|
-
*/
|
|
320
|
-
asciiOnly?: boolean;
|
|
321
|
-
/**
|
|
322
|
-
* Currently noop.
|
|
323
|
-
* @default false
|
|
324
|
-
*/
|
|
325
|
-
beautify?: boolean;
|
|
326
|
-
/**
|
|
327
|
-
* Currently noop.
|
|
328
|
-
* @default false
|
|
329
|
-
*/
|
|
330
|
-
braces?: boolean;
|
|
331
|
-
/**
|
|
332
|
-
* - `false`: removes all comments
|
|
333
|
-
* - `'some'`: preserves some comments
|
|
334
|
-
* - `'all'`: preserves all comments
|
|
335
|
-
* - `{ regex: string }`: preserves comments that match the regex
|
|
336
|
-
* @default false
|
|
337
|
-
*/
|
|
338
|
-
comments?: false | "some" | "all" | {
|
|
339
|
-
regex: string;
|
|
340
|
-
};
|
|
341
|
-
/**
|
|
342
|
-
* Currently noop.
|
|
343
|
-
* @default 5
|
|
344
|
-
*/
|
|
345
|
-
ecma?: TerserEcmaVersion;
|
|
346
|
-
/**
|
|
347
|
-
* Currently noop.
|
|
348
|
-
* @alias indent_level
|
|
349
|
-
*/
|
|
350
|
-
indentLevel?: number;
|
|
351
|
-
/**
|
|
352
|
-
* Currently noop.
|
|
353
|
-
* @alias indent_start
|
|
354
|
-
*/
|
|
355
|
-
indentStart?: number;
|
|
356
|
-
/**
|
|
357
|
-
* Currently noop.
|
|
358
|
-
* @alias inline_script
|
|
359
|
-
*/
|
|
360
|
-
inlineScript?: boolean;
|
|
361
|
-
/**
|
|
362
|
-
* Currently noop.
|
|
363
|
-
* @alias keep_numbers
|
|
364
|
-
*/
|
|
365
|
-
keepNumbers?: number;
|
|
366
|
-
/**
|
|
367
|
-
* Currently noop.
|
|
368
|
-
* @alias keep_quoted_props
|
|
369
|
-
*/
|
|
370
|
-
keepQuotedProps?: boolean;
|
|
371
|
-
/**
|
|
372
|
-
* Currently noop.
|
|
373
|
-
* @alias max_line_len
|
|
374
|
-
*/
|
|
375
|
-
maxLineLen?: number | false;
|
|
376
|
-
/**
|
|
377
|
-
* Currently noop.
|
|
378
|
-
*/
|
|
379
|
-
preamble?: string;
|
|
380
|
-
/**
|
|
381
|
-
* Currently noop.
|
|
382
|
-
* @alias quote_keys
|
|
383
|
-
*/
|
|
384
|
-
quoteKeys?: boolean;
|
|
385
|
-
/**
|
|
386
|
-
* Currently noop.
|
|
387
|
-
* @alias quote_style
|
|
388
|
-
*/
|
|
389
|
-
quoteStyle?: boolean;
|
|
390
|
-
/**
|
|
391
|
-
* Currently noop.
|
|
392
|
-
* @alias preserve_annotations
|
|
393
|
-
*/
|
|
394
|
-
preserveAnnotations?: boolean;
|
|
395
|
-
/**
|
|
396
|
-
* Currently noop.
|
|
397
|
-
*/
|
|
398
|
-
safari10?: boolean;
|
|
399
|
-
/**
|
|
400
|
-
* Currently noop.
|
|
401
|
-
*/
|
|
402
|
-
semicolons?: boolean;
|
|
403
|
-
/**
|
|
404
|
-
* Currently noop.
|
|
405
|
-
*/
|
|
406
|
-
shebang?: boolean;
|
|
407
|
-
/**
|
|
408
|
-
* Currently noop.
|
|
409
|
-
*/
|
|
410
|
-
webkit?: boolean;
|
|
411
|
-
/**
|
|
412
|
-
* Currently noop.
|
|
413
|
-
* @alias wrap_iife
|
|
414
|
-
*/
|
|
415
|
-
wrapIife?: boolean;
|
|
416
|
-
/**
|
|
417
|
-
* Currently noop.
|
|
418
|
-
* @alias wrap_func_args
|
|
419
|
-
*/
|
|
420
|
-
wrapFuncArgs?: boolean;
|
|
421
|
-
}
|
|
422
|
-
interface TerserCompressOptions {
|
|
423
|
-
arguments?: boolean;
|
|
424
|
-
arrows?: boolean;
|
|
425
|
-
booleans?: boolean;
|
|
426
|
-
booleans_as_integers?: boolean;
|
|
427
|
-
collapse_vars?: boolean;
|
|
428
|
-
comparisons?: boolean;
|
|
429
|
-
computed_props?: boolean;
|
|
430
|
-
conditionals?: boolean;
|
|
431
|
-
dead_code?: boolean;
|
|
432
|
-
defaults?: boolean;
|
|
433
|
-
directives?: boolean;
|
|
434
|
-
drop_console?: boolean;
|
|
435
|
-
drop_debugger?: boolean;
|
|
436
|
-
ecma?: TerserEcmaVersion;
|
|
437
|
-
evaluate?: boolean;
|
|
438
|
-
expression?: boolean;
|
|
439
|
-
global_defs?: any;
|
|
440
|
-
hoist_funs?: boolean;
|
|
441
|
-
hoist_props?: boolean;
|
|
442
|
-
hoist_vars?: boolean;
|
|
443
|
-
ie8?: boolean;
|
|
444
|
-
if_return?: boolean;
|
|
445
|
-
inline?: 0 | 1 | 2 | 3;
|
|
446
|
-
join_vars?: boolean;
|
|
447
|
-
keep_classnames?: boolean;
|
|
448
|
-
keep_fargs?: boolean;
|
|
449
|
-
keep_fnames?: boolean;
|
|
450
|
-
keep_infinity?: boolean;
|
|
451
|
-
loops?: boolean;
|
|
452
|
-
negate_iife?: boolean;
|
|
453
|
-
passes?: number;
|
|
454
|
-
properties?: boolean;
|
|
455
|
-
pure_getters?: any;
|
|
456
|
-
pure_funcs?: string[];
|
|
457
|
-
reduce_funcs?: boolean;
|
|
458
|
-
reduce_vars?: boolean;
|
|
459
|
-
sequences?: any;
|
|
460
|
-
side_effects?: boolean;
|
|
461
|
-
switches?: boolean;
|
|
462
|
-
top_retain?: any;
|
|
463
|
-
toplevel?: any;
|
|
464
|
-
typeofs?: boolean;
|
|
465
|
-
unsafe?: boolean;
|
|
466
|
-
unsafe_passes?: boolean;
|
|
467
|
-
unsafe_arrows?: boolean;
|
|
468
|
-
unsafe_comps?: boolean;
|
|
469
|
-
unsafe_function?: boolean;
|
|
470
|
-
unsafe_math?: boolean;
|
|
471
|
-
unsafe_symbols?: boolean;
|
|
472
|
-
unsafe_methods?: boolean;
|
|
473
|
-
unsafe_proto?: boolean;
|
|
474
|
-
unsafe_regexp?: boolean;
|
|
475
|
-
unsafe_undefined?: boolean;
|
|
476
|
-
unused?: boolean;
|
|
477
|
-
const_to_let?: boolean;
|
|
478
|
-
module?: boolean;
|
|
479
|
-
}
|
|
480
|
-
interface TerserMangleOptions {
|
|
481
|
-
props?: TerserManglePropertiesOptions;
|
|
482
|
-
/**
|
|
483
|
-
* Pass `true` to mangle names declared in the top level scope.
|
|
484
|
-
*/
|
|
485
|
-
topLevel?: boolean;
|
|
486
|
-
/**
|
|
487
|
-
* @deprecated An alias for compatibility with terser.
|
|
488
|
-
*/
|
|
489
|
-
toplevel?: boolean;
|
|
490
|
-
/**
|
|
491
|
-
* Pass `true` to not mangle class names.
|
|
492
|
-
*/
|
|
493
|
-
keepClassNames?: boolean;
|
|
494
|
-
/**
|
|
495
|
-
* @deprecated An alias for compatibility with terser.
|
|
496
|
-
*/
|
|
497
|
-
keep_classnames?: boolean;
|
|
498
|
-
/**
|
|
499
|
-
* Pass `true` to not mangle function names.
|
|
500
|
-
*/
|
|
501
|
-
keepFnNames?: boolean;
|
|
502
|
-
/**
|
|
503
|
-
* @deprecated An alias for compatibility with terser.
|
|
504
|
-
*/
|
|
505
|
-
keep_fnames?: boolean;
|
|
506
|
-
/**
|
|
507
|
-
* Pass `true` to not mangle private props.
|
|
508
|
-
*/
|
|
509
|
-
keepPrivateProps?: boolean;
|
|
510
|
-
/**
|
|
511
|
-
* @deprecated An alias for compatibility with terser.
|
|
512
|
-
*/
|
|
513
|
-
keep_private_props?: boolean;
|
|
514
|
-
ie8?: boolean;
|
|
515
|
-
safari10?: boolean;
|
|
516
|
-
reserved?: string[];
|
|
517
|
-
}
|
|
518
|
-
interface TerserManglePropertiesOptions {
|
|
519
|
-
}
|
|
520
|
-
/**
|
|
521
|
-
* Programmatic options.
|
|
522
|
-
*/
|
|
523
|
-
interface Options extends Config {
|
|
524
|
-
/**
|
|
525
|
-
* If true, a file is parsed as a script instead of module.
|
|
526
|
-
*/
|
|
527
|
-
script?: boolean;
|
|
528
|
-
/**
|
|
529
|
-
* The working directory that all paths in the programmatic
|
|
530
|
-
* options will be resolved relative to.
|
|
531
|
-
*
|
|
532
|
-
* Defaults to `process.cwd()`.
|
|
533
|
-
*/
|
|
534
|
-
cwd?: string;
|
|
535
|
-
caller?: CallerOptions;
|
|
536
|
-
/** The filename associated with the code currently being compiled,
|
|
537
|
-
* if there is one. The filename is optional, but not all of Swc's
|
|
538
|
-
* functionality is available when the filename is unknown, because a
|
|
539
|
-
* subset of options rely on the filename for their functionality.
|
|
540
|
-
*
|
|
541
|
-
* The three primary cases users could run into are:
|
|
542
|
-
*
|
|
543
|
-
* - The filename is exposed to plugins. Some plugins may require the
|
|
544
|
-
* presence of the filename.
|
|
545
|
-
* - Options like "test", "exclude", and "ignore" require the filename
|
|
546
|
-
* for string/RegExp matching.
|
|
547
|
-
* - .swcrc files are loaded relative to the file being compiled.
|
|
548
|
-
* If this option is omitted, Swc will behave as if swcrc: false has been set.
|
|
549
|
-
*/
|
|
550
|
-
filename?: string;
|
|
551
|
-
/**
|
|
552
|
-
* The initial path that will be processed based on the "rootMode" to
|
|
553
|
-
* determine the conceptual root folder for the current Swc project.
|
|
554
|
-
* This is used in two primary cases:
|
|
555
|
-
*
|
|
556
|
-
* - The base directory when checking for the default "configFile" value
|
|
557
|
-
* - The default value for "swcrcRoots".
|
|
558
|
-
*
|
|
559
|
-
* Defaults to `opts.cwd`
|
|
560
|
-
*/
|
|
561
|
-
root?: string;
|
|
562
|
-
/**
|
|
563
|
-
* This option, combined with the "root" value, defines how Swc chooses
|
|
564
|
-
* its project root. The different modes define different ways that Swc
|
|
565
|
-
* can process the "root" value to get the final project root.
|
|
566
|
-
*
|
|
567
|
-
* "root" - Passes the "root" value through as unchanged.
|
|
568
|
-
* "upward" - Walks upward from the "root" directory, looking for a directory
|
|
569
|
-
* containing a swc.config.js file, and throws an error if a swc.config.js
|
|
570
|
-
* is not found.
|
|
571
|
-
* "upward-optional" - Walk upward from the "root" directory, looking for
|
|
572
|
-
* a directory containing a swc.config.js file, and falls back to "root"
|
|
573
|
-
* if a swc.config.js is not found.
|
|
574
|
-
*
|
|
575
|
-
*
|
|
576
|
-
* "root" is the default mode because it avoids the risk that Swc
|
|
577
|
-
* will accidentally load a swc.config.js that is entirely outside
|
|
578
|
-
* of the current project folder. If you use "upward-optional",
|
|
579
|
-
* be aware that it will walk up the directory structure all the
|
|
580
|
-
* way to the filesystem root, and it is always possible that someone
|
|
581
|
-
* will have a forgotten swc.config.js in their home directory,
|
|
582
|
-
* which could cause unexpected errors in your builds.
|
|
583
|
-
*
|
|
584
|
-
*
|
|
585
|
-
* Users with monorepo project structures that run builds/tests on a
|
|
586
|
-
* per-package basis may well want to use "upward" since monorepos
|
|
587
|
-
* often have a swc.config.js in the project root. Running Swc
|
|
588
|
-
* in a monorepo subdirectory without "upward", will cause Swc
|
|
589
|
-
* to skip loading any swc.config.js files in the project root,
|
|
590
|
-
* which can lead to unexpected errors and compilation failure.
|
|
591
|
-
*/
|
|
592
|
-
rootMode?: "root" | "upward" | "upward-optional";
|
|
593
|
-
/**
|
|
594
|
-
* The current active environment used during configuration loading.
|
|
595
|
-
* This value is used as the key when resolving "env" configs,
|
|
596
|
-
* and is also available inside configuration functions, plugins,
|
|
597
|
-
* and presets, via the api.env() function.
|
|
598
|
-
*
|
|
599
|
-
* Defaults to `process.env.SWC_ENV || "production" || "development"`
|
|
600
|
-
*/
|
|
601
|
-
envName?: string;
|
|
602
|
-
/**
|
|
603
|
-
* Defaults to searching for a default `.swcrc` file, but can
|
|
604
|
-
* be passed the path of any JS or JSON5 config file.
|
|
605
|
-
*
|
|
606
|
-
*
|
|
607
|
-
* NOTE: This option does not affect loading of .swcrc files,
|
|
608
|
-
* so while it may be tempting to do configFile: "./foo/.swcrc",
|
|
609
|
-
* it is not recommended. If the given .swcrc is loaded via the
|
|
610
|
-
* standard file-relative logic, you'll end up loading the same
|
|
611
|
-
* config file twice, merging it with itself. If you are linking
|
|
612
|
-
* a specific config file, it is recommended to stick with a
|
|
613
|
-
* naming scheme that is independent of the "swcrc" name.
|
|
614
|
-
*
|
|
615
|
-
* Defaults to `path.resolve(opts.root, ".swcrc")`
|
|
616
|
-
*/
|
|
617
|
-
configFile?: string | boolean;
|
|
618
|
-
/**
|
|
619
|
-
* true will enable searching for configuration files relative to the "filename" provided to Swc.
|
|
620
|
-
*
|
|
621
|
-
* A swcrc value passed in the programmatic options will override one set within a configuration file.
|
|
622
|
-
*
|
|
623
|
-
* Note: .swcrc files are only loaded if the current "filename" is inside of
|
|
624
|
-
* a package that matches one of the "swcrcRoots" packages.
|
|
625
|
-
*
|
|
626
|
-
*
|
|
627
|
-
* Defaults to true as long as the filename option has been specified
|
|
628
|
-
*/
|
|
629
|
-
swcrc?: boolean;
|
|
630
|
-
/**
|
|
631
|
-
* By default, Babel will only search for .babelrc files within the "root" package
|
|
632
|
-
* because otherwise Babel cannot know if a given .babelrc is meant to be loaded,
|
|
633
|
-
* or if it's "plugins" and "presets" have even been installed, since the file
|
|
634
|
-
* being compiled could be inside node_modules, or have been symlinked into the project.
|
|
635
|
-
*
|
|
636
|
-
*
|
|
637
|
-
* This option allows users to provide a list of other packages that should be
|
|
638
|
-
* considered "root" packages when considering whether to load .babelrc files.
|
|
639
|
-
*
|
|
640
|
-
*
|
|
641
|
-
* For example, a monorepo setup that wishes to allow individual packages
|
|
642
|
-
* to have their own configs might want to do
|
|
643
|
-
*
|
|
644
|
-
*
|
|
645
|
-
*
|
|
646
|
-
* Defaults to `opts.root`
|
|
647
|
-
*/
|
|
648
|
-
swcrcRoots?: boolean | MatchPattern | MatchPattern[];
|
|
649
|
-
/**
|
|
650
|
-
* `true` will attempt to load an input sourcemap from the file itself, if it
|
|
651
|
-
* contains a //# sourceMappingURL=... comment. If no map is found, or the
|
|
652
|
-
* map fails to load and parse, it will be silently discarded.
|
|
653
|
-
*
|
|
654
|
-
* If an object is provided, it will be treated as the source map object itself.
|
|
655
|
-
*
|
|
656
|
-
* Defaults to `true`.
|
|
657
|
-
*/
|
|
658
|
-
inputSourceMap?: boolean | string;
|
|
659
|
-
/**
|
|
660
|
-
* The name to use for the file inside the source map object.
|
|
661
|
-
*
|
|
662
|
-
* Defaults to `path.basename(opts.filenameRelative)` when available, or `"unknown"`.
|
|
663
|
-
*/
|
|
664
|
-
sourceFileName?: string;
|
|
665
|
-
/**
|
|
666
|
-
* The sourceRoot fields to set in the generated source map, if one is desired.
|
|
667
|
-
*/
|
|
668
|
-
sourceRoot?: string;
|
|
669
|
-
plugin?: Plugin;
|
|
670
|
-
isModule?: boolean | "unknown" | "commonjs";
|
|
671
|
-
/**
|
|
672
|
-
* Destination path. Note that this value is used only to fix source path
|
|
673
|
-
* of source map files and swc does not write output to this path.
|
|
674
|
-
*/
|
|
675
|
-
outputPath?: string;
|
|
676
|
-
}
|
|
677
|
-
interface CallerOptions {
|
|
678
|
-
name: string;
|
|
679
|
-
[key: string]: any;
|
|
680
|
-
}
|
|
681
|
-
/**
|
|
682
|
-
* .swcrc
|
|
683
|
-
*/
|
|
684
|
-
interface Config {
|
|
685
|
-
/**
|
|
686
|
-
* Note: The type is string because it follows rust's regex syntax.
|
|
687
|
-
*/
|
|
688
|
-
test?: string | string[];
|
|
689
|
-
/**
|
|
690
|
-
* Note: The type is string because it follows rust's regex syntax.
|
|
691
|
-
*/
|
|
692
|
-
exclude?: string | string[];
|
|
693
|
-
env?: EnvConfig;
|
|
694
|
-
jsc?: JscConfig;
|
|
695
|
-
module?: ModuleConfig;
|
|
696
|
-
minify?: boolean;
|
|
697
|
-
/**
|
|
698
|
-
* - true to generate a sourcemap for the code and include it in the result object.
|
|
699
|
-
* - "inline" to generate a sourcemap and append it as a data URL to the end of the code, but not include it in the result object.
|
|
700
|
-
*
|
|
701
|
-
* `swc-cli` overloads some of these to also affect how maps are written to disk:
|
|
702
|
-
*
|
|
703
|
-
* - true will write the map to a .map file on disk
|
|
704
|
-
* - "inline" will write the file directly, so it will have a data: containing the map
|
|
705
|
-
* - Note: These options are bit weird, so it may make the most sense to just use true
|
|
706
|
-
* and handle the rest in your own code, depending on your use case.
|
|
707
|
-
*/
|
|
708
|
-
sourceMaps?: boolean | "inline";
|
|
709
|
-
inlineSourcesContent?: boolean;
|
|
710
|
-
}
|
|
711
|
-
/**
|
|
712
|
-
* Configuration ported from babel-preset-env
|
|
713
|
-
*/
|
|
714
|
-
interface EnvConfig {
|
|
715
|
-
mode?: "usage" | "entry";
|
|
716
|
-
debug?: boolean;
|
|
717
|
-
dynamicImport?: boolean;
|
|
718
|
-
loose?: boolean;
|
|
719
|
-
/**
|
|
720
|
-
* Transpiles the broken syntax to the closest non-broken modern syntax
|
|
721
|
-
*
|
|
722
|
-
* Defaults to false.
|
|
723
|
-
*/
|
|
724
|
-
bugfixes?: boolean;
|
|
725
|
-
skip?: string[];
|
|
726
|
-
include?: string[];
|
|
727
|
-
exclude?: string[];
|
|
728
|
-
/**
|
|
729
|
-
* The version of the used core js.
|
|
730
|
-
*
|
|
731
|
-
*/
|
|
732
|
-
coreJs?: string;
|
|
733
|
-
targets?: any;
|
|
734
|
-
path?: string;
|
|
735
|
-
shippedProposals?: boolean;
|
|
736
|
-
/**
|
|
737
|
-
* Enable all transforms
|
|
738
|
-
*/
|
|
739
|
-
forceAllTransforms?: boolean;
|
|
740
|
-
}
|
|
741
|
-
interface JscConfig {
|
|
742
|
-
assumptions?: Assumptions;
|
|
743
|
-
loose?: boolean;
|
|
744
|
-
/**
|
|
745
|
-
* Defaults to EsParserConfig
|
|
746
|
-
*/
|
|
747
|
-
parser?: ParserConfig;
|
|
748
|
-
transform?: TransformConfig;
|
|
749
|
-
/**
|
|
750
|
-
* Use `@swc/helpers` instead of inline helpers.
|
|
751
|
-
*/
|
|
752
|
-
externalHelpers?: boolean;
|
|
753
|
-
/**
|
|
754
|
-
* Defaults to `es3` (which enabled **all** pass).
|
|
755
|
-
*/
|
|
756
|
-
target?: JscTarget;
|
|
757
|
-
/**
|
|
758
|
-
* Keep class names.
|
|
759
|
-
*/
|
|
760
|
-
keepClassNames?: boolean;
|
|
761
|
-
/**
|
|
762
|
-
* This is experimental, and can be removed without a major version bump.
|
|
763
|
-
*/
|
|
764
|
-
experimental?: {
|
|
765
|
-
optimizeHygiene?: boolean;
|
|
766
|
-
/**
|
|
767
|
-
* Preserve `with` in imports and exports.
|
|
768
|
-
*
|
|
769
|
-
* @deprecated Use `keepImportAssertions` instead.
|
|
770
|
-
*/
|
|
771
|
-
keepImportAttributes?: boolean;
|
|
772
|
-
/**
|
|
773
|
-
* Use `assert` instead of `with` for imports and exports.
|
|
774
|
-
* This option only works when `keepImportAttributes` is `true`.
|
|
775
|
-
*/
|
|
776
|
-
emitAssertForImportAttributes?: boolean;
|
|
777
|
-
/**
|
|
778
|
-
* Specify the location where SWC stores its intermediate cache files.
|
|
779
|
-
* Currently only transform plugin uses this. If not specified, SWC will
|
|
780
|
-
* create `.swc` directories.
|
|
781
|
-
*/
|
|
782
|
-
cacheRoot?: string;
|
|
783
|
-
/**
|
|
784
|
-
* List of custom transform plugins written in WebAssembly.
|
|
785
|
-
* First parameter of tuple indicates the name of the plugin - it can be either
|
|
786
|
-
* a name of the npm package can be resolved, or absolute path to .wasm binary.
|
|
787
|
-
*
|
|
788
|
-
* Second parameter of tuple is JSON based configuration for the plugin.
|
|
789
|
-
*/
|
|
790
|
-
plugins?: WasmPlugin[];
|
|
791
|
-
/**
|
|
792
|
-
* Run Wasm plugins before stripping TypeScript or decorators.
|
|
793
|
-
*
|
|
794
|
-
* See https://github.com/swc-project/swc/issues/9132 for more details.
|
|
795
|
-
*/
|
|
796
|
-
runPluginFirst?: boolean;
|
|
797
|
-
/**
|
|
798
|
-
* Disable builtin transforms. If enabled, only Wasm plugins are used.
|
|
799
|
-
*/
|
|
800
|
-
disableBuiltinTransformsForInternalTesting?: boolean;
|
|
801
|
-
/**
|
|
802
|
-
* Emit isolated dts files for each module.
|
|
803
|
-
*/
|
|
804
|
-
emitIsolatedDts?: boolean;
|
|
805
|
-
/**
|
|
806
|
-
* Disable all lint rules.
|
|
807
|
-
*/
|
|
808
|
-
disableAllLints?: boolean;
|
|
809
|
-
/**
|
|
810
|
-
* Keep import assertions.
|
|
811
|
-
*/
|
|
812
|
-
keepImportAssertions?: boolean;
|
|
813
|
-
};
|
|
814
|
-
baseUrl?: string;
|
|
815
|
-
paths?: {
|
|
816
|
-
[from: string]: string[];
|
|
817
|
-
};
|
|
818
|
-
minify?: JsMinifyOptions;
|
|
819
|
-
preserveAllComments?: boolean;
|
|
820
|
-
output?: {
|
|
821
|
-
/**
|
|
822
|
-
* This can be used to keep the output ascii-only.
|
|
823
|
-
* If this option is set, `minify.format.asciiOnly` will be ignored.
|
|
824
|
-
* @default 'utf8'
|
|
825
|
-
*/
|
|
826
|
-
charset?: 'utf8' | 'ascii';
|
|
827
|
-
};
|
|
828
|
-
}
|
|
829
|
-
type JscTarget = "es3" | "es5" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "es2023" | "es2024" | "esnext";
|
|
830
|
-
type ParserConfig = TsParserConfig | EsParserConfig;
|
|
831
|
-
interface TsParserConfig {
|
|
832
|
-
syntax: "typescript";
|
|
833
|
-
/**
|
|
834
|
-
* Defaults to `false`.
|
|
835
|
-
*/
|
|
836
|
-
tsx?: boolean;
|
|
837
|
-
/**
|
|
838
|
-
* Defaults to `false`.
|
|
839
|
-
*/
|
|
840
|
-
decorators?: boolean;
|
|
841
|
-
/**
|
|
842
|
-
* @deprecated Always true because it's in ecmascript spec.
|
|
843
|
-
*/
|
|
844
|
-
dynamicImport?: boolean;
|
|
845
|
-
}
|
|
846
|
-
interface EsParserConfig {
|
|
847
|
-
syntax: "ecmascript";
|
|
848
|
-
/**
|
|
849
|
-
* Defaults to false.
|
|
850
|
-
*/
|
|
851
|
-
jsx?: boolean;
|
|
852
|
-
/**
|
|
853
|
-
* @deprecated Always true because it's in ecmascript spec.
|
|
854
|
-
*/
|
|
855
|
-
numericSeparator?: boolean;
|
|
856
|
-
/**
|
|
857
|
-
* @deprecated Always true because it's in ecmascript spec.
|
|
858
|
-
*/
|
|
859
|
-
classPrivateProperty?: boolean;
|
|
860
|
-
/**
|
|
861
|
-
* @deprecated Always true because it's in ecmascript spec.
|
|
862
|
-
*/
|
|
863
|
-
privateMethod?: boolean;
|
|
864
|
-
/**
|
|
865
|
-
* @deprecated Always true because it's in ecmascript spec.
|
|
866
|
-
*/
|
|
867
|
-
classProperty?: boolean;
|
|
868
|
-
/**
|
|
869
|
-
* Defaults to `false`
|
|
870
|
-
*/
|
|
871
|
-
functionBind?: boolean;
|
|
872
|
-
/**
|
|
873
|
-
* Defaults to `false`
|
|
874
|
-
*/
|
|
875
|
-
decorators?: boolean;
|
|
876
|
-
/**
|
|
877
|
-
* Defaults to `false`
|
|
878
|
-
*/
|
|
879
|
-
decoratorsBeforeExport?: boolean;
|
|
880
|
-
/**
|
|
881
|
-
* Defaults to `false`
|
|
882
|
-
*/
|
|
883
|
-
exportDefaultFrom?: boolean;
|
|
884
|
-
/**
|
|
885
|
-
* @deprecated Always true because it's in ecmascript spec.
|
|
886
|
-
*/
|
|
887
|
-
exportNamespaceFrom?: boolean;
|
|
888
|
-
/**
|
|
889
|
-
* @deprecated Always true because it's in ecmascript spec.
|
|
890
|
-
*/
|
|
891
|
-
dynamicImport?: boolean;
|
|
892
|
-
/**
|
|
893
|
-
* @deprecated Always true because it's in ecmascript spec.
|
|
894
|
-
*/
|
|
895
|
-
nullishCoalescing?: boolean;
|
|
896
|
-
/**
|
|
897
|
-
* @deprecated Always true because it's in ecmascript spec.
|
|
898
|
-
*/
|
|
899
|
-
optionalChaining?: boolean;
|
|
900
|
-
/**
|
|
901
|
-
* @deprecated Always true because it's in ecmascript spec.
|
|
902
|
-
*/
|
|
903
|
-
importMeta?: boolean;
|
|
904
|
-
/**
|
|
905
|
-
* @deprecated Always true because it's in ecmascript spec.
|
|
906
|
-
*/
|
|
907
|
-
topLevelAwait?: boolean;
|
|
908
|
-
/**
|
|
909
|
-
* @deprecated An alias of `importAttributes`
|
|
910
|
-
*/
|
|
911
|
-
importAssertions?: boolean;
|
|
912
|
-
/**
|
|
913
|
-
* @deprecated Always true in swc
|
|
914
|
-
*/
|
|
915
|
-
importAttributes?: boolean;
|
|
916
|
-
/**
|
|
917
|
-
* Defaults to `false`
|
|
918
|
-
*/
|
|
919
|
-
allowSuperOutsideMethod?: boolean;
|
|
920
|
-
/**
|
|
921
|
-
* Defaults to `false`
|
|
922
|
-
*/
|
|
923
|
-
allowReturnOutsideFunction?: boolean;
|
|
924
|
-
/**
|
|
925
|
-
* Defaults to `false`
|
|
926
|
-
*/
|
|
927
|
-
autoAccessors?: boolean;
|
|
928
|
-
/**
|
|
929
|
-
* Defaults to `false`
|
|
930
|
-
*/
|
|
931
|
-
explicitResourceManagement?: boolean;
|
|
932
|
-
}
|
|
933
|
-
/**
|
|
934
|
-
* Options for transform.
|
|
935
|
-
*/
|
|
936
|
-
interface TransformConfig {
|
|
937
|
-
/**
|
|
938
|
-
* Effective only if `syntax` supports ƒ.
|
|
939
|
-
*/
|
|
940
|
-
react?: ReactConfig;
|
|
941
|
-
constModules?: ConstModulesConfig;
|
|
942
|
-
/**
|
|
943
|
-
* Defaults to null, which skips optimizer pass.
|
|
944
|
-
*/
|
|
945
|
-
optimizer?: OptimizerConfig;
|
|
946
|
-
/**
|
|
947
|
-
* https://swc.rs/docs/configuration/compilation#jsctransformlegacydecorator
|
|
948
|
-
*/
|
|
949
|
-
legacyDecorator?: boolean;
|
|
950
|
-
/**
|
|
951
|
-
* https://swc.rs/docs/configuration/compilation#jsctransformdecoratormetadata
|
|
952
|
-
*/
|
|
953
|
-
decoratorMetadata?: boolean;
|
|
954
|
-
/**
|
|
955
|
-
* https://swc.rs/docs/configuration/compilation#jsctransformdecoratorversion
|
|
956
|
-
*/
|
|
957
|
-
decoratorVersion?: "2021-12" | "2022-03";
|
|
958
|
-
treatConstEnumAsEnum?: boolean;
|
|
959
|
-
/**
|
|
960
|
-
* https://www.typescriptlang.org/tsconfig#useDefineForClassFields
|
|
961
|
-
*/
|
|
962
|
-
useDefineForClassFields?: boolean;
|
|
963
|
-
/**
|
|
964
|
-
* https://www.typescriptlang.org/tsconfig#verbatimModuleSyntax
|
|
965
|
-
*/
|
|
966
|
-
verbatimModuleSyntax?: boolean;
|
|
967
|
-
tsEnumIsMutable?: boolean;
|
|
968
|
-
}
|
|
969
|
-
interface ReactConfig {
|
|
970
|
-
/**
|
|
971
|
-
* Replace the function used when compiling JSX expressions.
|
|
972
|
-
*
|
|
973
|
-
* Defaults to `React.createElement`.
|
|
974
|
-
*/
|
|
975
|
-
pragma?: string;
|
|
976
|
-
/**
|
|
977
|
-
* Replace the component used when compiling JSX fragments.
|
|
978
|
-
*
|
|
979
|
-
* Defaults to `React.Fragment`
|
|
980
|
-
*/
|
|
981
|
-
pragmaFrag?: string;
|
|
982
|
-
/**
|
|
983
|
-
* Toggles whether or not to throw an error if a XML namespaced tag name is used. For example:
|
|
984
|
-
* `<f:image />`
|
|
985
|
-
*
|
|
986
|
-
* Though the JSX spec allows this, it is disabled by default since React's
|
|
987
|
-
* JSX does not currently have support for it.
|
|
988
|
-
*
|
|
989
|
-
*/
|
|
990
|
-
throwIfNamespace?: boolean;
|
|
991
|
-
/**
|
|
992
|
-
* Toggles plugins that aid in development, such as @swc/plugin-transform-react-jsx-self
|
|
993
|
-
* and @swc/plugin-transform-react-jsx-source.
|
|
994
|
-
*
|
|
995
|
-
* Defaults to `false`,
|
|
996
|
-
*
|
|
997
|
-
*/
|
|
998
|
-
development?: boolean;
|
|
999
|
-
/**
|
|
1000
|
-
* Use `Object.assign()` instead of `_extends`. Defaults to false.
|
|
1001
|
-
* @deprecated
|
|
1002
|
-
*/
|
|
1003
|
-
useBuiltins?: boolean;
|
|
1004
|
-
/**
|
|
1005
|
-
* Enable fast refresh feature for React app
|
|
1006
|
-
*/
|
|
1007
|
-
refresh?: boolean | {
|
|
1008
|
-
/**
|
|
1009
|
-
* Identifier for the `react-refresh` register function.
|
|
1010
|
-
*
|
|
1011
|
-
* Defaults to `$RefreshReg$`
|
|
1012
|
-
*/
|
|
1013
|
-
refreshReg?: string;
|
|
1014
|
-
/**
|
|
1015
|
-
* Identifier for the `react-refresh` signature function.
|
|
1016
|
-
*
|
|
1017
|
-
* Defaults to `$RefreshSig$`
|
|
1018
|
-
*/
|
|
1019
|
-
refreshSig?: string;
|
|
1020
|
-
/**
|
|
1021
|
-
* Flag to emit full signatures.
|
|
1022
|
-
*
|
|
1023
|
-
* Defaults to `false`
|
|
1024
|
-
*/
|
|
1025
|
-
emitFullSignatures?: boolean;
|
|
1026
|
-
};
|
|
1027
|
-
/**
|
|
1028
|
-
* Decides which runtime to use when transforming JSX.
|
|
1029
|
-
* - `"automatic"` - Automatically imports the functions that JSX transpiles to.
|
|
1030
|
-
* This is the modern approach introduced in React 17+ that eliminates the need to
|
|
1031
|
-
* manually import React in every file that uses JSX.
|
|
1032
|
-
* - `"classic"` - Uses the traditional JSX transform that relies on `React.createElement`
|
|
1033
|
-
* calls. Requires React to be in scope, which was the standard behavior before React 17.
|
|
1034
|
-
* - `"preserve"` - Leaves JSX syntax unchanged without transforming it.
|
|
1035
|
-
* @default "classic"
|
|
1036
|
-
*/
|
|
1037
|
-
runtime?: "automatic" | "classic" | "preserve";
|
|
1038
|
-
/**
|
|
1039
|
-
* Declares the module specifier to be used for importing the `jsx` and `jsxs` factory
|
|
1040
|
-
* functions when using `runtime` 'automatic'
|
|
1041
|
-
* @default "react"
|
|
1042
|
-
*/
|
|
1043
|
-
importSource?: string;
|
|
1044
|
-
}
|
|
1045
|
-
/**
|
|
1046
|
-
* - `import { DEBUG } from '@ember/env-flags';`
|
|
1047
|
-
* - `import { FEATURE_A, FEATURE_B } from '@ember/features';`
|
|
1048
|
-
*
|
|
1049
|
-
* See: https://github.com/swc-project/swc/issues/18#issuecomment-466272558
|
|
1050
|
-
*/
|
|
1051
|
-
interface ConstModulesConfig {
|
|
1052
|
-
globals?: {
|
|
1053
|
-
[module: string]: {
|
|
1054
|
-
[name: string]: string;
|
|
1055
|
-
};
|
|
1056
|
-
};
|
|
1057
|
-
}
|
|
1058
|
-
interface OptimizerConfig {
|
|
1059
|
-
simplify?: boolean;
|
|
1060
|
-
globals?: GlobalPassOption;
|
|
1061
|
-
jsonify?: {
|
|
1062
|
-
minCost: number;
|
|
1063
|
-
};
|
|
1064
|
-
}
|
|
1065
|
-
/**
|
|
1066
|
-
* Options for inline-global pass.
|
|
1067
|
-
*/
|
|
1068
|
-
interface GlobalPassOption {
|
|
1069
|
-
/**
|
|
1070
|
-
* Global variables that should be inlined with passed value.
|
|
1071
|
-
*
|
|
1072
|
-
* e.g. `{ __DEBUG__: true }`
|
|
1073
|
-
*/
|
|
1074
|
-
vars?: Record<string, string>;
|
|
1075
|
-
/**
|
|
1076
|
-
* Names of environment variables that should be inlined with the value of corresponding env during build.
|
|
1077
|
-
*
|
|
1078
|
-
* Defaults to `["NODE_ENV", "SWC_ENV"]`
|
|
1079
|
-
*/
|
|
1080
|
-
envs?: string[] | Record<string, string>;
|
|
1081
|
-
/**
|
|
1082
|
-
* Replaces typeof calls for passed variables with corresponding value
|
|
1083
|
-
*
|
|
1084
|
-
* e.g. `{ window: 'object' }`
|
|
1085
|
-
*/
|
|
1086
|
-
typeofs?: Record<string, string>;
|
|
1087
|
-
}
|
|
1088
|
-
type ModuleConfig = Es6Config | CommonJsConfig | UmdConfig | AmdConfig | NodeNextConfig | SystemjsConfig;
|
|
1089
|
-
interface BaseModuleConfig {
|
|
1090
|
-
/**
|
|
1091
|
-
* By default, when using exports with babel a non-enumerable `__esModule`
|
|
1092
|
-
* property is exported. In some cases this property is used to determine
|
|
1093
|
-
* if the import is the default export or if it contains the default export.
|
|
1094
|
-
*
|
|
1095
|
-
* In order to prevent the __esModule property from being exported, you
|
|
1096
|
-
* can set the strict option to true.
|
|
1097
|
-
*
|
|
1098
|
-
* Defaults to `false`.
|
|
1099
|
-
*/
|
|
1100
|
-
strict?: boolean;
|
|
1101
|
-
/**
|
|
1102
|
-
* Emits 'use strict' directive.
|
|
1103
|
-
*
|
|
1104
|
-
* Defaults to `true`.
|
|
1105
|
-
*/
|
|
1106
|
-
strictMode?: boolean;
|
|
1107
|
-
/**
|
|
1108
|
-
* Changes Babel's compiled import statements to be lazily evaluated when their imported bindings are used for the first time.
|
|
1109
|
-
*
|
|
1110
|
-
* This can improve initial load time of your module because evaluating dependencies up
|
|
1111
|
-
* front is sometimes entirely un-necessary. This is especially the case when implementing
|
|
1112
|
-
* a library module.
|
|
1113
|
-
*
|
|
1114
|
-
*
|
|
1115
|
-
* The value of `lazy` has a few possible effects:
|
|
1116
|
-
*
|
|
1117
|
-
* - `false` - No lazy initialization of any imported module.
|
|
1118
|
-
* - `true` - Do not lazy-initialize local `./foo` imports, but lazy-init `foo` dependencies.
|
|
1119
|
-
*
|
|
1120
|
-
* Local paths are much more likely to have circular dependencies, which may break if loaded lazily,
|
|
1121
|
-
* so they are not lazy by default, whereas dependencies between independent modules are rarely cyclical.
|
|
1122
|
-
*
|
|
1123
|
-
* - `Array<string>` - Lazy-initialize all imports with source matching one of the given strings.
|
|
1124
|
-
*
|
|
1125
|
-
* -----
|
|
1126
|
-
*
|
|
1127
|
-
* The two cases where imports can never be lazy are:
|
|
1128
|
-
*
|
|
1129
|
-
* - `import "foo";`
|
|
1130
|
-
*
|
|
1131
|
-
* Side-effect imports are automatically non-lazy since their very existence means
|
|
1132
|
-
* that there is no binding to later kick off initialization.
|
|
1133
|
-
*
|
|
1134
|
-
* - `export * from "foo"`
|
|
1135
|
-
*
|
|
1136
|
-
* Re-exporting all names requires up-front execution because otherwise there is no
|
|
1137
|
-
* way to know what names need to be exported.
|
|
1138
|
-
*
|
|
1139
|
-
* Defaults to `false`.
|
|
1140
|
-
*/
|
|
1141
|
-
lazy?: boolean | string[];
|
|
1142
|
-
/**
|
|
1143
|
-
* @deprecated Use the `importInterop` option instead.
|
|
1144
|
-
*
|
|
1145
|
-
* By default, when using exports with swc a non-enumerable __esModule property is exported.
|
|
1146
|
-
* This property is then used to determine if the import is the default export or if
|
|
1147
|
-
* it contains the default export.
|
|
1148
|
-
*
|
|
1149
|
-
* In cases where the auto-unwrapping of default is not needed, you can set the noInterop option
|
|
1150
|
-
* to true to avoid the usage of the interopRequireDefault helper (shown in inline form above).
|
|
1151
|
-
*
|
|
1152
|
-
* Defaults to `false`.
|
|
1153
|
-
*/
|
|
1154
|
-
noInterop?: boolean;
|
|
1155
|
-
/**
|
|
1156
|
-
* Defaults to `swc`.
|
|
1157
|
-
*
|
|
1158
|
-
* CommonJS modules and ECMAScript modules are not fully compatible.
|
|
1159
|
-
* However, compilers, bundlers and JavaScript runtimes developed different strategies
|
|
1160
|
-
* to make them work together as well as possible.
|
|
1161
|
-
*
|
|
1162
|
-
* - `swc` (alias: `babel`)
|
|
1163
|
-
*
|
|
1164
|
-
* When using exports with `swc` a non-enumerable `__esModule` property is exported
|
|
1165
|
-
* This property is then used to determine if the import is the default export
|
|
1166
|
-
* or if it contains the default export.
|
|
1167
|
-
*
|
|
1168
|
-
* ```javascript
|
|
1169
|
-
* import foo from "foo";
|
|
1170
|
-
* import { bar } from "bar";
|
|
1171
|
-
* foo;
|
|
1172
|
-
* bar;
|
|
1173
|
-
*
|
|
1174
|
-
* // Is compiled to ...
|
|
1175
|
-
*
|
|
1176
|
-
* "use strict";
|
|
1177
|
-
*
|
|
1178
|
-
* function _interop_require_default(obj) {
|
|
1179
|
-
* return obj && obj.__esModule ? obj : { default: obj };
|
|
1180
|
-
* }
|
|
1181
|
-
*
|
|
1182
|
-
* var _foo = _interop_require_default(require("foo"));
|
|
1183
|
-
* var _bar = require("bar");
|
|
1184
|
-
*
|
|
1185
|
-
* _foo.default;
|
|
1186
|
-
* _bar.bar;
|
|
1187
|
-
* ```
|
|
1188
|
-
*
|
|
1189
|
-
* When this import interop is used, if both the imported and the importer module are compiled
|
|
1190
|
-
* with swc they behave as if none of them was compiled.
|
|
1191
|
-
*
|
|
1192
|
-
* This is the default behavior.
|
|
1193
|
-
*
|
|
1194
|
-
* - `node`
|
|
1195
|
-
*
|
|
1196
|
-
* When importing CommonJS files (either directly written in CommonJS, or generated with a compiler)
|
|
1197
|
-
* Node.js always binds the `default` export to the value of `module.exports`.
|
|
1198
|
-
*
|
|
1199
|
-
* ```javascript
|
|
1200
|
-
* import foo from "foo";
|
|
1201
|
-
* import { bar } from "bar";
|
|
1202
|
-
* foo;
|
|
1203
|
-
* bar;
|
|
1204
|
-
*
|
|
1205
|
-
* // Is compiled to ...
|
|
1206
|
-
*
|
|
1207
|
-
* "use strict";
|
|
1208
|
-
*
|
|
1209
|
-
* var _foo = require("foo");
|
|
1210
|
-
* var _bar = require("bar");
|
|
1211
|
-
*
|
|
1212
|
-
* _foo;
|
|
1213
|
-
* _bar.bar;
|
|
1214
|
-
* ```
|
|
1215
|
-
* This is not exactly the same as what Node.js does since swc allows accessing any property of `module.exports`
|
|
1216
|
-
* as a named export, while Node.js only allows importing statically analyzable properties of `module.exports`.
|
|
1217
|
-
* However, any import working in Node.js will also work when compiled with swc using `importInterop: "node"`.
|
|
1218
|
-
*
|
|
1219
|
-
* - `none`
|
|
1220
|
-
*
|
|
1221
|
-
* If you know that the imported file has been transformed with a compiler that stores the `default` export on
|
|
1222
|
-
* `exports.default` (such as swc or Babel), you can safely omit the `_interop_require_default` helper.
|
|
1223
|
-
*
|
|
1224
|
-
* ```javascript
|
|
1225
|
-
* import foo from "foo";
|
|
1226
|
-
* import { bar } from "bar";
|
|
1227
|
-
* foo;
|
|
1228
|
-
* bar;
|
|
1229
|
-
*
|
|
1230
|
-
* // Is compiled to ...
|
|
1231
|
-
*
|
|
1232
|
-
* "use strict";
|
|
1233
|
-
*
|
|
1234
|
-
* var _foo = require("foo");
|
|
1235
|
-
* var _bar = require("bar");
|
|
1236
|
-
*
|
|
1237
|
-
* _foo.default;
|
|
1238
|
-
* _bar.bar;
|
|
1239
|
-
* ```
|
|
1240
|
-
*/
|
|
1241
|
-
importInterop?: "swc" | "babel" | "node" | "none";
|
|
1242
|
-
/**
|
|
1243
|
-
* Output extension for generated files.
|
|
1244
|
-
*
|
|
1245
|
-
* Defaults to `js`.
|
|
1246
|
-
*/
|
|
1247
|
-
outFileExtension?: "js" | "mjs" | "cjs";
|
|
1248
|
-
/**
|
|
1249
|
-
* Emits `cjs-module-lexer` annotation
|
|
1250
|
-
* `cjs-module-lexer` is used in Node.js core for detecting the named exports available when importing a CJS module into ESM.
|
|
1251
|
-
* swc will emit `cjs-module-lexer` detectable annotation with this option enabled.
|
|
1252
|
-
*
|
|
1253
|
-
* Defaults to `true` if import_interop is Node, else `false`
|
|
1254
|
-
*/
|
|
1255
|
-
exportInteropAnnotation?: boolean;
|
|
1256
|
-
/**
|
|
1257
|
-
* If set to true, dynamic imports will be preserved.
|
|
1258
|
-
*/
|
|
1259
|
-
ignoreDynamic?: boolean;
|
|
1260
|
-
allowTopLevelThis?: boolean;
|
|
1261
|
-
preserveImportMeta?: boolean;
|
|
1262
|
-
/**
|
|
1263
|
-
* If set to true, This will resolve top .mjs
|
|
1264
|
-
*/
|
|
1265
|
-
resolveFully?: boolean;
|
|
1266
|
-
}
|
|
1267
|
-
interface Es6Config extends BaseModuleConfig {
|
|
1268
|
-
type: "es6";
|
|
1269
|
-
}
|
|
1270
|
-
interface NodeNextConfig extends BaseModuleConfig {
|
|
1271
|
-
type: "nodenext";
|
|
1272
|
-
}
|
|
1273
|
-
interface CommonJsConfig extends BaseModuleConfig {
|
|
1274
|
-
type: "commonjs";
|
|
1275
|
-
}
|
|
1276
|
-
interface UmdConfig extends BaseModuleConfig {
|
|
1277
|
-
type: "umd";
|
|
1278
|
-
globals?: {
|
|
1279
|
-
[key: string]: string;
|
|
1280
|
-
};
|
|
1281
|
-
}
|
|
1282
|
-
interface AmdConfig extends BaseModuleConfig {
|
|
1283
|
-
type: "amd";
|
|
1284
|
-
moduleId?: string;
|
|
1285
|
-
}
|
|
1286
|
-
interface SystemjsConfig {
|
|
1287
|
-
type: "systemjs";
|
|
1288
|
-
allowTopLevelThis?: boolean;
|
|
1289
|
-
}
|
|
1290
|
-
interface MatchPattern {
|
|
1291
|
-
}
|
|
1292
|
-
interface Span {
|
|
1293
|
-
start: number;
|
|
1294
|
-
end: number;
|
|
1295
|
-
ctxt: number;
|
|
1296
|
-
}
|
|
1297
|
-
interface Node {
|
|
1298
|
-
type: string;
|
|
1299
|
-
}
|
|
1300
|
-
interface HasSpan {
|
|
1301
|
-
span: Span;
|
|
1302
|
-
}
|
|
1303
|
-
interface HasDecorator {
|
|
1304
|
-
decorators?: Decorator[];
|
|
1305
|
-
}
|
|
1306
|
-
interface Class extends HasSpan, HasDecorator {
|
|
1307
|
-
body: ClassMember[];
|
|
1308
|
-
superClass?: Expression;
|
|
1309
|
-
isAbstract: boolean;
|
|
1310
|
-
typeParams?: TsTypeParameterDeclaration;
|
|
1311
|
-
superTypeParams?: TsTypeParameterInstantiation;
|
|
1312
|
-
implements: TsExpressionWithTypeArguments[];
|
|
1313
|
-
}
|
|
1314
|
-
type ClassMember = Constructor | ClassMethod | PrivateMethod | ClassProperty | PrivateProperty | TsIndexSignature | EmptyStatement | StaticBlock;
|
|
1315
|
-
interface ClassPropertyBase extends Node, HasSpan, HasDecorator {
|
|
1316
|
-
value?: Expression;
|
|
1317
|
-
typeAnnotation?: TsTypeAnnotation;
|
|
1318
|
-
isStatic: boolean;
|
|
1319
|
-
accessibility?: Accessibility;
|
|
1320
|
-
isOptional: boolean;
|
|
1321
|
-
isOverride: boolean;
|
|
1322
|
-
readonly: boolean;
|
|
1323
|
-
definite: boolean;
|
|
1324
|
-
}
|
|
1325
|
-
interface ClassProperty extends ClassPropertyBase {
|
|
1326
|
-
type: "ClassProperty";
|
|
1327
|
-
key: PropertyName;
|
|
1328
|
-
isAbstract: boolean;
|
|
1329
|
-
declare: boolean;
|
|
1330
|
-
}
|
|
1331
|
-
interface PrivateProperty extends ClassPropertyBase {
|
|
1332
|
-
type: "PrivateProperty";
|
|
1333
|
-
key: PrivateName;
|
|
1334
|
-
}
|
|
1335
|
-
interface Param extends Node, HasSpan, HasDecorator {
|
|
1336
|
-
type: "Parameter";
|
|
1337
|
-
pat: Pattern;
|
|
1338
|
-
}
|
|
1339
|
-
interface Constructor extends Node, HasSpan {
|
|
1340
|
-
type: "Constructor";
|
|
1341
|
-
key: PropertyName;
|
|
1342
|
-
params: (TsParameterProperty | Param)[];
|
|
1343
|
-
body?: BlockStatement;
|
|
1344
|
-
accessibility?: Accessibility;
|
|
1345
|
-
isOptional: boolean;
|
|
1346
|
-
}
|
|
1347
|
-
interface ClassMethodBase extends Node, HasSpan {
|
|
1348
|
-
function: Fn;
|
|
1349
|
-
kind: MethodKind;
|
|
1350
|
-
isStatic: boolean;
|
|
1351
|
-
accessibility?: Accessibility;
|
|
1352
|
-
isAbstract: boolean;
|
|
1353
|
-
isOptional: boolean;
|
|
1354
|
-
isOverride: boolean;
|
|
1355
|
-
}
|
|
1356
|
-
interface ClassMethod extends ClassMethodBase {
|
|
1357
|
-
type: "ClassMethod";
|
|
1358
|
-
key: PropertyName;
|
|
1359
|
-
}
|
|
1360
|
-
interface PrivateMethod extends ClassMethodBase {
|
|
1361
|
-
type: "PrivateMethod";
|
|
1362
|
-
key: PrivateName;
|
|
1363
|
-
}
|
|
1364
|
-
interface StaticBlock extends Node, HasSpan {
|
|
1365
|
-
type: "StaticBlock";
|
|
1366
|
-
body: BlockStatement;
|
|
1367
|
-
}
|
|
1368
|
-
interface Decorator extends Node, HasSpan {
|
|
1369
|
-
type: "Decorator";
|
|
1370
|
-
expression: Expression;
|
|
1371
|
-
}
|
|
1372
|
-
type MethodKind = "method" | "getter" | "setter";
|
|
1373
|
-
type Declaration = ClassDeclaration | FunctionDeclaration | VariableDeclaration | TsInterfaceDeclaration | TsTypeAliasDeclaration | TsEnumDeclaration | TsModuleDeclaration;
|
|
1374
|
-
interface FunctionDeclaration extends Fn {
|
|
1375
|
-
type: "FunctionDeclaration";
|
|
1376
|
-
identifier: Identifier;
|
|
1377
|
-
declare: boolean;
|
|
1378
|
-
}
|
|
1379
|
-
interface ClassDeclaration extends Class, Node {
|
|
1380
|
-
type: "ClassDeclaration";
|
|
1381
|
-
identifier: Identifier;
|
|
1382
|
-
declare: boolean;
|
|
1383
|
-
}
|
|
1384
|
-
interface VariableDeclaration extends Node, HasSpan {
|
|
1385
|
-
type: "VariableDeclaration";
|
|
1386
|
-
kind: VariableDeclarationKind;
|
|
1387
|
-
declare: boolean;
|
|
1388
|
-
declarations: VariableDeclarator[];
|
|
1389
|
-
}
|
|
1390
|
-
type VariableDeclarationKind = "var" | "let" | "const";
|
|
1391
|
-
interface VariableDeclarator extends Node, HasSpan {
|
|
1392
|
-
type: "VariableDeclarator";
|
|
1393
|
-
id: Pattern;
|
|
1394
|
-
init?: Expression;
|
|
1395
|
-
definite: boolean;
|
|
1396
|
-
}
|
|
1397
|
-
type Expression = ThisExpression | ArrayExpression | ObjectExpression | FunctionExpression | UnaryExpression | UpdateExpression | BinaryExpression | AssignmentExpression | MemberExpression | SuperPropExpression | ConditionalExpression | CallExpression | NewExpression | SequenceExpression | Identifier | Literal | TemplateLiteral | TaggedTemplateExpression | ArrowFunctionExpression | ClassExpression | YieldExpression | MetaProperty | AwaitExpression | ParenthesisExpression | JSXMemberExpression | JSXNamespacedName | JSXEmptyExpression | JSXElement | JSXFragment | TsTypeAssertion | TsConstAssertion | TsNonNullExpression | TsAsExpression | TsSatisfiesExpression | TsInstantiation | PrivateName | OptionalChainingExpression | Invalid;
|
|
1398
|
-
interface ExpressionBase extends Node, HasSpan {
|
|
1399
|
-
}
|
|
1400
|
-
interface Identifier extends ExpressionBase {
|
|
1401
|
-
type: "Identifier";
|
|
1402
|
-
value: string;
|
|
1403
|
-
optional: boolean;
|
|
1404
|
-
}
|
|
1405
|
-
interface OptionalChainingExpression extends ExpressionBase {
|
|
1406
|
-
type: "OptionalChainingExpression";
|
|
1407
|
-
questionDotToken: Span;
|
|
1408
|
-
/**
|
|
1409
|
-
* Call expression or member expression.
|
|
1410
|
-
*/
|
|
1411
|
-
base: MemberExpression | OptionalChainingCall;
|
|
1412
|
-
}
|
|
1413
|
-
interface OptionalChainingCall extends ExpressionBase {
|
|
1414
|
-
type: "CallExpression";
|
|
1415
|
-
callee: Expression;
|
|
1416
|
-
arguments: ExprOrSpread[];
|
|
1417
|
-
typeArguments?: TsTypeParameterInstantiation;
|
|
1418
|
-
}
|
|
1419
|
-
interface ThisExpression extends ExpressionBase {
|
|
1420
|
-
type: "ThisExpression";
|
|
1421
|
-
}
|
|
1422
|
-
interface ArrayExpression extends ExpressionBase {
|
|
1423
|
-
type: "ArrayExpression";
|
|
1424
|
-
elements: (ExprOrSpread | undefined)[];
|
|
1425
|
-
}
|
|
1426
|
-
interface ExprOrSpread {
|
|
1427
|
-
spread?: Span;
|
|
1428
|
-
expression: Expression;
|
|
1429
|
-
}
|
|
1430
|
-
interface ObjectExpression extends ExpressionBase {
|
|
1431
|
-
type: "ObjectExpression";
|
|
1432
|
-
properties: (SpreadElement | Property)[];
|
|
1433
|
-
}
|
|
1434
|
-
interface Argument {
|
|
1435
|
-
spread?: Span;
|
|
1436
|
-
expression: Expression;
|
|
1437
|
-
}
|
|
1438
|
-
interface SpreadElement extends Node {
|
|
1439
|
-
type: "SpreadElement";
|
|
1440
|
-
spread: Span;
|
|
1441
|
-
arguments: Expression;
|
|
1442
|
-
}
|
|
1443
|
-
interface UnaryExpression extends ExpressionBase {
|
|
1444
|
-
type: "UnaryExpression";
|
|
1445
|
-
operator: UnaryOperator;
|
|
1446
|
-
argument: Expression;
|
|
1447
|
-
}
|
|
1448
|
-
interface UpdateExpression extends ExpressionBase {
|
|
1449
|
-
type: "UpdateExpression";
|
|
1450
|
-
operator: UpdateOperator;
|
|
1451
|
-
prefix: boolean;
|
|
1452
|
-
argument: Expression;
|
|
1453
|
-
}
|
|
1454
|
-
interface BinaryExpression extends ExpressionBase {
|
|
1455
|
-
type: "BinaryExpression";
|
|
1456
|
-
operator: BinaryOperator;
|
|
1457
|
-
left: Expression;
|
|
1458
|
-
right: Expression;
|
|
1459
|
-
}
|
|
1460
|
-
interface FunctionExpression extends Fn, ExpressionBase {
|
|
1461
|
-
type: "FunctionExpression";
|
|
1462
|
-
identifier?: Identifier;
|
|
1463
|
-
}
|
|
1464
|
-
interface ClassExpression extends Class, ExpressionBase {
|
|
1465
|
-
type: "ClassExpression";
|
|
1466
|
-
identifier?: Identifier;
|
|
1467
|
-
}
|
|
1468
|
-
interface AssignmentExpression extends ExpressionBase {
|
|
1469
|
-
type: "AssignmentExpression";
|
|
1470
|
-
operator: AssignmentOperator;
|
|
1471
|
-
left: Expression | Pattern;
|
|
1472
|
-
right: Expression;
|
|
1473
|
-
}
|
|
1474
|
-
interface MemberExpression extends ExpressionBase {
|
|
1475
|
-
type: "MemberExpression";
|
|
1476
|
-
object: Expression;
|
|
1477
|
-
property: Identifier | PrivateName | ComputedPropName;
|
|
1478
|
-
}
|
|
1479
|
-
interface SuperPropExpression extends ExpressionBase {
|
|
1480
|
-
type: "SuperPropExpression";
|
|
1481
|
-
obj: Super;
|
|
1482
|
-
property: Identifier | ComputedPropName;
|
|
1483
|
-
}
|
|
1484
|
-
interface ConditionalExpression extends ExpressionBase {
|
|
1485
|
-
type: "ConditionalExpression";
|
|
1486
|
-
test: Expression;
|
|
1487
|
-
consequent: Expression;
|
|
1488
|
-
alternate: Expression;
|
|
1489
|
-
}
|
|
1490
|
-
interface Super extends Node, HasSpan {
|
|
1491
|
-
type: "Super";
|
|
1492
|
-
}
|
|
1493
|
-
interface Import extends Node, HasSpan {
|
|
1494
|
-
type: "Import";
|
|
1495
|
-
}
|
|
1496
|
-
interface CallExpression extends ExpressionBase {
|
|
1497
|
-
type: "CallExpression";
|
|
1498
|
-
callee: Super | Import | Expression;
|
|
1499
|
-
arguments: Argument[];
|
|
1500
|
-
typeArguments?: TsTypeParameterInstantiation;
|
|
1501
|
-
}
|
|
1502
|
-
interface NewExpression extends ExpressionBase {
|
|
1503
|
-
type: "NewExpression";
|
|
1504
|
-
callee: Expression;
|
|
1505
|
-
arguments?: Argument[];
|
|
1506
|
-
typeArguments?: TsTypeParameterInstantiation;
|
|
1507
|
-
}
|
|
1508
|
-
interface SequenceExpression extends ExpressionBase {
|
|
1509
|
-
type: "SequenceExpression";
|
|
1510
|
-
expressions: Expression[];
|
|
1511
|
-
}
|
|
1512
|
-
interface ArrowFunctionExpression extends ExpressionBase {
|
|
1513
|
-
type: "ArrowFunctionExpression";
|
|
1514
|
-
params: Pattern[];
|
|
1515
|
-
body: BlockStatement | Expression;
|
|
1516
|
-
async: boolean;
|
|
1517
|
-
generator: boolean;
|
|
1518
|
-
typeParameters?: TsTypeParameterDeclaration;
|
|
1519
|
-
returnType?: TsTypeAnnotation;
|
|
1520
|
-
}
|
|
1521
|
-
interface YieldExpression extends ExpressionBase {
|
|
1522
|
-
type: "YieldExpression";
|
|
1523
|
-
argument?: Expression;
|
|
1524
|
-
delegate: boolean;
|
|
1525
|
-
}
|
|
1526
|
-
interface MetaProperty extends Node, HasSpan {
|
|
1527
|
-
type: "MetaProperty";
|
|
1528
|
-
kind: "new.target" | "import.meta";
|
|
1529
|
-
}
|
|
1530
|
-
interface AwaitExpression extends ExpressionBase {
|
|
1531
|
-
type: "AwaitExpression";
|
|
1532
|
-
argument: Expression;
|
|
1533
|
-
}
|
|
1534
|
-
interface TemplateLiteral extends ExpressionBase {
|
|
1535
|
-
type: "TemplateLiteral";
|
|
1536
|
-
expressions: Expression[];
|
|
1537
|
-
quasis: TemplateElement[];
|
|
1538
|
-
}
|
|
1539
|
-
interface TaggedTemplateExpression extends ExpressionBase {
|
|
1540
|
-
type: "TaggedTemplateExpression";
|
|
1541
|
-
tag: Expression;
|
|
1542
|
-
typeParameters?: TsTypeParameterInstantiation;
|
|
1543
|
-
template: TemplateLiteral;
|
|
1544
|
-
}
|
|
1545
|
-
interface TemplateElement extends ExpressionBase {
|
|
1546
|
-
type: "TemplateElement";
|
|
1547
|
-
tail: boolean;
|
|
1548
|
-
cooked?: string;
|
|
1549
|
-
raw: string;
|
|
1550
|
-
}
|
|
1551
|
-
interface ParenthesisExpression extends ExpressionBase {
|
|
1552
|
-
type: "ParenthesisExpression";
|
|
1553
|
-
expression: Expression;
|
|
1554
|
-
}
|
|
1555
|
-
interface Fn extends HasSpan, HasDecorator {
|
|
1556
|
-
params: Param[];
|
|
1557
|
-
body?: BlockStatement;
|
|
1558
|
-
generator: boolean;
|
|
1559
|
-
async: boolean;
|
|
1560
|
-
typeParameters?: TsTypeParameterDeclaration;
|
|
1561
|
-
returnType?: TsTypeAnnotation;
|
|
1562
|
-
}
|
|
1563
|
-
interface PatternBase extends Node, HasSpan {
|
|
1564
|
-
typeAnnotation?: TsTypeAnnotation;
|
|
1565
|
-
}
|
|
1566
|
-
interface PrivateName extends ExpressionBase {
|
|
1567
|
-
type: "PrivateName";
|
|
1568
|
-
id: Identifier;
|
|
1569
|
-
}
|
|
1570
|
-
type JSXObject = JSXMemberExpression | Identifier;
|
|
1571
|
-
interface JSXMemberExpression extends Node {
|
|
1572
|
-
type: "JSXMemberExpression";
|
|
1573
|
-
object: JSXObject;
|
|
1574
|
-
property: Identifier;
|
|
1575
|
-
}
|
|
1576
|
-
/**
|
|
1577
|
-
* XML-based namespace syntax:
|
|
1578
|
-
*/
|
|
1579
|
-
interface JSXNamespacedName extends Node {
|
|
1580
|
-
type: "JSXNamespacedName";
|
|
1581
|
-
namespace: Identifier;
|
|
1582
|
-
name: Identifier;
|
|
1583
|
-
}
|
|
1584
|
-
interface JSXEmptyExpression extends Node, HasSpan {
|
|
1585
|
-
type: "JSXEmptyExpression";
|
|
1586
|
-
}
|
|
1587
|
-
interface JSXExpressionContainer extends Node, HasSpan {
|
|
1588
|
-
type: "JSXExpressionContainer";
|
|
1589
|
-
expression: JSXExpression;
|
|
1590
|
-
}
|
|
1591
|
-
type JSXExpression = JSXEmptyExpression | Expression;
|
|
1592
|
-
interface JSXSpreadChild extends Node, HasSpan {
|
|
1593
|
-
type: "JSXSpreadChild";
|
|
1594
|
-
expression: Expression;
|
|
1595
|
-
}
|
|
1596
|
-
type JSXElementName = Identifier | JSXMemberExpression | JSXNamespacedName;
|
|
1597
|
-
interface JSXOpeningElement extends Node, HasSpan {
|
|
1598
|
-
type: "JSXOpeningElement";
|
|
1599
|
-
name: JSXElementName;
|
|
1600
|
-
attributes: JSXAttributeOrSpread[];
|
|
1601
|
-
selfClosing: boolean;
|
|
1602
|
-
typeArguments?: TsTypeParameterInstantiation;
|
|
1603
|
-
}
|
|
1604
|
-
type JSXAttributeOrSpread = JSXAttribute | SpreadElement;
|
|
1605
|
-
interface JSXClosingElement extends Node, HasSpan {
|
|
1606
|
-
type: "JSXClosingElement";
|
|
1607
|
-
name: JSXElementName;
|
|
1608
|
-
}
|
|
1609
|
-
interface JSXAttribute extends Node, HasSpan {
|
|
1610
|
-
type: "JSXAttribute";
|
|
1611
|
-
name: JSXAttributeName;
|
|
1612
|
-
value?: JSXAttrValue;
|
|
1613
|
-
}
|
|
1614
|
-
type JSXAttributeName = Identifier | JSXNamespacedName;
|
|
1615
|
-
type JSXAttrValue = Literal | JSXExpressionContainer | JSXElement | JSXFragment;
|
|
1616
|
-
interface JSXText extends Node, HasSpan {
|
|
1617
|
-
type: "JSXText";
|
|
1618
|
-
value: string;
|
|
1619
|
-
raw: string;
|
|
1620
|
-
}
|
|
1621
|
-
interface JSXElement extends Node, HasSpan {
|
|
1622
|
-
type: "JSXElement";
|
|
1623
|
-
opening: JSXOpeningElement;
|
|
1624
|
-
children: JSXElementChild[];
|
|
1625
|
-
closing?: JSXClosingElement;
|
|
1626
|
-
}
|
|
1627
|
-
type JSXElementChild = JSXText | JSXExpressionContainer | JSXSpreadChild | JSXElement | JSXFragment;
|
|
1628
|
-
interface JSXFragment extends Node, HasSpan {
|
|
1629
|
-
type: "JSXFragment";
|
|
1630
|
-
opening: JSXOpeningFragment;
|
|
1631
|
-
children: JSXElementChild[];
|
|
1632
|
-
closing: JSXClosingFragment;
|
|
1633
|
-
}
|
|
1634
|
-
interface JSXOpeningFragment extends Node, HasSpan {
|
|
1635
|
-
type: "JSXOpeningFragment";
|
|
1636
|
-
}
|
|
1637
|
-
interface JSXClosingFragment extends Node, HasSpan {
|
|
1638
|
-
type: "JSXClosingFragment";
|
|
1639
|
-
}
|
|
1640
|
-
type Literal = StringLiteral | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | JSXText;
|
|
1641
|
-
interface StringLiteral extends Node, HasSpan {
|
|
1642
|
-
type: "StringLiteral";
|
|
1643
|
-
value: string;
|
|
1644
|
-
raw?: string;
|
|
1645
|
-
}
|
|
1646
|
-
interface BooleanLiteral extends Node, HasSpan {
|
|
1647
|
-
type: "BooleanLiteral";
|
|
1648
|
-
value: boolean;
|
|
1649
|
-
}
|
|
1650
|
-
interface NullLiteral extends Node, HasSpan {
|
|
1651
|
-
type: "NullLiteral";
|
|
1652
|
-
}
|
|
1653
|
-
interface RegExpLiteral extends Node, HasSpan {
|
|
1654
|
-
type: "RegExpLiteral";
|
|
1655
|
-
pattern: string;
|
|
1656
|
-
flags: string;
|
|
1657
|
-
}
|
|
1658
|
-
interface NumericLiteral extends Node, HasSpan {
|
|
1659
|
-
type: "NumericLiteral";
|
|
1660
|
-
value: number;
|
|
1661
|
-
raw?: string;
|
|
1662
|
-
}
|
|
1663
|
-
interface BigIntLiteral extends Node, HasSpan {
|
|
1664
|
-
type: "BigIntLiteral";
|
|
1665
|
-
value: bigint;
|
|
1666
|
-
raw?: string;
|
|
1667
|
-
}
|
|
1668
|
-
type ModuleDeclaration = ImportDeclaration | ExportDeclaration | ExportNamedDeclaration | ExportDefaultDeclaration | ExportDefaultExpression | ExportAllDeclaration | TsImportEqualsDeclaration | TsExportAssignment | TsNamespaceExportDeclaration;
|
|
1669
|
-
interface ExportDefaultExpression extends Node, HasSpan {
|
|
1670
|
-
type: "ExportDefaultExpression";
|
|
1671
|
-
expression: Expression;
|
|
1672
|
-
}
|
|
1673
|
-
interface ExportDeclaration extends Node, HasSpan {
|
|
1674
|
-
type: "ExportDeclaration";
|
|
1675
|
-
declaration: Declaration;
|
|
1676
|
-
}
|
|
1677
|
-
interface ImportDeclaration extends Node, HasSpan {
|
|
1678
|
-
type: "ImportDeclaration";
|
|
1679
|
-
specifiers: ImportSpecifier[];
|
|
1680
|
-
source: StringLiteral;
|
|
1681
|
-
typeOnly: boolean;
|
|
1682
|
-
asserts?: ObjectExpression;
|
|
1683
|
-
}
|
|
1684
|
-
interface ExportAllDeclaration extends Node, HasSpan {
|
|
1685
|
-
type: "ExportAllDeclaration";
|
|
1686
|
-
source: StringLiteral;
|
|
1687
|
-
asserts?: ObjectExpression;
|
|
1688
|
-
}
|
|
1689
|
-
/**
|
|
1690
|
-
* - `export { foo } from 'mod'`
|
|
1691
|
-
* - `export { foo as bar } from 'mod'`
|
|
1692
|
-
*/
|
|
1693
|
-
interface ExportNamedDeclaration extends Node, HasSpan {
|
|
1694
|
-
type: "ExportNamedDeclaration";
|
|
1695
|
-
specifiers: ExportSpecifier[];
|
|
1696
|
-
source?: StringLiteral;
|
|
1697
|
-
typeOnly: boolean;
|
|
1698
|
-
asserts?: ObjectExpression;
|
|
1699
|
-
}
|
|
1700
|
-
interface ExportDefaultDeclaration extends Node, HasSpan {
|
|
1701
|
-
type: "ExportDefaultDeclaration";
|
|
1702
|
-
decl: DefaultDecl;
|
|
1703
|
-
}
|
|
1704
|
-
type DefaultDecl = ClassExpression | FunctionExpression | TsInterfaceDeclaration;
|
|
1705
|
-
type ImportSpecifier = NamedImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier;
|
|
1706
|
-
/**
|
|
1707
|
-
* e.g. `import foo from 'mod.js'`
|
|
1708
|
-
*/
|
|
1709
|
-
interface ImportDefaultSpecifier extends Node, HasSpan {
|
|
1710
|
-
type: "ImportDefaultSpecifier";
|
|
1711
|
-
local: Identifier;
|
|
1712
|
-
}
|
|
1713
|
-
/**
|
|
1714
|
-
* e.g. `import * as foo from 'mod.js'`.
|
|
1715
|
-
*/
|
|
1716
|
-
interface ImportNamespaceSpecifier extends Node, HasSpan {
|
|
1717
|
-
type: "ImportNamespaceSpecifier";
|
|
1718
|
-
local: Identifier;
|
|
1719
|
-
}
|
|
1720
|
-
/**
|
|
1721
|
-
* e.g. - `import { foo } from 'mod.js'`
|
|
1722
|
-
*
|
|
1723
|
-
* local = foo, imported = None
|
|
1724
|
-
*
|
|
1725
|
-
* e.g. `import { foo as bar } from 'mod.js'`
|
|
1726
|
-
*
|
|
1727
|
-
* local = bar, imported = Some(foo) for
|
|
1728
|
-
*/
|
|
1729
|
-
interface NamedImportSpecifier extends Node, HasSpan {
|
|
1730
|
-
type: "ImportSpecifier";
|
|
1731
|
-
local: Identifier;
|
|
1732
|
-
imported?: ModuleExportName;
|
|
1733
|
-
isTypeOnly: boolean;
|
|
1734
|
-
}
|
|
1735
|
-
type ModuleExportName = Identifier | StringLiteral;
|
|
1736
|
-
type ExportSpecifier = ExportNamespaceSpecifier | ExportDefaultSpecifier | NamedExportSpecifier;
|
|
1737
|
-
/**
|
|
1738
|
-
* `export * as foo from 'src';`
|
|
1739
|
-
*/
|
|
1740
|
-
interface ExportNamespaceSpecifier extends Node, HasSpan {
|
|
1741
|
-
type: "ExportNamespaceSpecifier";
|
|
1742
|
-
name: ModuleExportName;
|
|
1743
|
-
}
|
|
1744
|
-
interface ExportDefaultSpecifier extends Node, HasSpan {
|
|
1745
|
-
type: "ExportDefaultSpecifier";
|
|
1746
|
-
exported: Identifier;
|
|
1747
|
-
}
|
|
1748
|
-
interface NamedExportSpecifier extends Node, HasSpan {
|
|
1749
|
-
type: "ExportSpecifier";
|
|
1750
|
-
orig: ModuleExportName;
|
|
1751
|
-
/**
|
|
1752
|
-
* `Some(bar)` in `export { foo as bar }`
|
|
1753
|
-
*/
|
|
1754
|
-
exported?: ModuleExportName;
|
|
1755
|
-
isTypeOnly: boolean;
|
|
1756
|
-
}
|
|
1757
|
-
interface HasInterpreter {
|
|
1758
|
-
/**
|
|
1759
|
-
* e.g. `/usr/bin/node` for `#!/usr/bin/node`
|
|
1760
|
-
*/
|
|
1761
|
-
interpreter: string;
|
|
1762
|
-
}
|
|
1763
|
-
type Program = Module | Script;
|
|
1764
|
-
interface Module extends Node, HasSpan, HasInterpreter {
|
|
1765
|
-
type: "Module";
|
|
1766
|
-
body: ModuleItem[];
|
|
1767
|
-
}
|
|
1768
|
-
interface Script extends Node, HasSpan, HasInterpreter {
|
|
1769
|
-
type: "Script";
|
|
1770
|
-
body: Statement[];
|
|
1771
|
-
}
|
|
1772
|
-
type ModuleItem = ModuleDeclaration | Statement;
|
|
1773
|
-
type BinaryOperator = "==" | "!=" | "===" | "!==" | "<" | "<=" | ">" | ">=" | "<<" | ">>" | ">>>" | "+" | "-" | "*" | "/" | "%" | "|" | "^" | "&" | "||" | "&&" | "in" | "instanceof" | "**" | "??";
|
|
1774
|
-
type AssignmentOperator = "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "<<=" | ">>=" | ">>>=" | "|=" | "^=" | "&=" | "**=" | "&&=" | "||=" | "??=";
|
|
1775
|
-
type UpdateOperator = "++" | "--";
|
|
1776
|
-
type UnaryOperator = "-" | "+" | "!" | "~" | "typeof" | "void" | "delete";
|
|
1777
|
-
type Pattern = BindingIdentifier | ArrayPattern | RestElement | ObjectPattern | AssignmentPattern | Invalid | Expression;
|
|
1778
|
-
interface BindingIdentifier extends PatternBase {
|
|
1779
|
-
type: "Identifier";
|
|
1780
|
-
value: string;
|
|
1781
|
-
optional: boolean;
|
|
1782
|
-
}
|
|
1783
|
-
interface ArrayPattern extends PatternBase {
|
|
1784
|
-
type: "ArrayPattern";
|
|
1785
|
-
elements: (Pattern | undefined)[];
|
|
1786
|
-
optional: boolean;
|
|
1787
|
-
}
|
|
1788
|
-
interface ObjectPattern extends PatternBase {
|
|
1789
|
-
type: "ObjectPattern";
|
|
1790
|
-
properties: ObjectPatternProperty[];
|
|
1791
|
-
optional: boolean;
|
|
1792
|
-
}
|
|
1793
|
-
interface AssignmentPattern extends PatternBase {
|
|
1794
|
-
type: "AssignmentPattern";
|
|
1795
|
-
left: Pattern;
|
|
1796
|
-
right: Expression;
|
|
1797
|
-
}
|
|
1798
|
-
interface RestElement extends PatternBase {
|
|
1799
|
-
type: "RestElement";
|
|
1800
|
-
rest: Span;
|
|
1801
|
-
argument: Pattern;
|
|
1802
|
-
}
|
|
1803
|
-
type ObjectPatternProperty = KeyValuePatternProperty | AssignmentPatternProperty | RestElement;
|
|
1804
|
-
/**
|
|
1805
|
-
* `{key: value}`
|
|
1806
|
-
*/
|
|
1807
|
-
interface KeyValuePatternProperty extends Node {
|
|
1808
|
-
type: "KeyValuePatternProperty";
|
|
1809
|
-
key: PropertyName;
|
|
1810
|
-
value: Pattern;
|
|
1811
|
-
}
|
|
1812
|
-
/**
|
|
1813
|
-
* `{key}` or `{key = value}`
|
|
1814
|
-
*/
|
|
1815
|
-
interface AssignmentPatternProperty extends Node, HasSpan {
|
|
1816
|
-
type: "AssignmentPatternProperty";
|
|
1817
|
-
key: Identifier;
|
|
1818
|
-
value?: Expression;
|
|
1819
|
-
}
|
|
1820
|
-
/** Identifier is `a` in `{ a, }` */
|
|
1821
|
-
type Property = Identifier | KeyValueProperty | AssignmentProperty | GetterProperty | SetterProperty | MethodProperty;
|
|
1822
|
-
interface PropBase extends Node {
|
|
1823
|
-
key: PropertyName;
|
|
1824
|
-
}
|
|
1825
|
-
interface KeyValueProperty extends PropBase {
|
|
1826
|
-
type: "KeyValueProperty";
|
|
1827
|
-
value: Expression;
|
|
1828
|
-
}
|
|
1829
|
-
interface AssignmentProperty extends Node {
|
|
1830
|
-
type: "AssignmentProperty";
|
|
1831
|
-
key: Identifier;
|
|
1832
|
-
value: Expression;
|
|
1833
|
-
}
|
|
1834
|
-
interface GetterProperty extends PropBase, HasSpan {
|
|
1835
|
-
type: "GetterProperty";
|
|
1836
|
-
typeAnnotation?: TsTypeAnnotation;
|
|
1837
|
-
body?: BlockStatement;
|
|
1838
|
-
}
|
|
1839
|
-
interface SetterProperty extends PropBase, HasSpan {
|
|
1840
|
-
type: "SetterProperty";
|
|
1841
|
-
param: Pattern;
|
|
1842
|
-
body?: BlockStatement;
|
|
1843
|
-
}
|
|
1844
|
-
interface MethodProperty extends PropBase, Fn {
|
|
1845
|
-
type: "MethodProperty";
|
|
1846
|
-
}
|
|
1847
|
-
type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropName | BigIntLiteral;
|
|
1848
|
-
interface ComputedPropName extends Node, HasSpan {
|
|
1849
|
-
type: "Computed";
|
|
1850
|
-
expression: Expression;
|
|
1851
|
-
}
|
|
1852
|
-
interface BlockStatement extends Node, HasSpan {
|
|
1853
|
-
type: "BlockStatement";
|
|
1854
|
-
stmts: Statement[];
|
|
1855
|
-
}
|
|
1856
|
-
interface ExpressionStatement extends Node, HasSpan {
|
|
1857
|
-
type: "ExpressionStatement";
|
|
1858
|
-
expression: Expression;
|
|
1859
|
-
}
|
|
1860
|
-
type Statement = BlockStatement | EmptyStatement | DebuggerStatement | WithStatement | ReturnStatement | LabeledStatement | BreakStatement | ContinueStatement | IfStatement | SwitchStatement | ThrowStatement | TryStatement | WhileStatement | DoWhileStatement | ForStatement | ForInStatement | ForOfStatement | Declaration | ExpressionStatement;
|
|
1861
|
-
interface EmptyStatement extends Node, HasSpan {
|
|
1862
|
-
type: "EmptyStatement";
|
|
1863
|
-
}
|
|
1864
|
-
interface DebuggerStatement extends Node, HasSpan {
|
|
1865
|
-
type: "DebuggerStatement";
|
|
1866
|
-
}
|
|
1867
|
-
interface WithStatement extends Node, HasSpan {
|
|
1868
|
-
type: "WithStatement";
|
|
1869
|
-
object: Expression;
|
|
1870
|
-
body: Statement;
|
|
1871
|
-
}
|
|
1872
|
-
interface ReturnStatement extends Node, HasSpan {
|
|
1873
|
-
type: "ReturnStatement";
|
|
1874
|
-
argument?: Expression;
|
|
1875
|
-
}
|
|
1876
|
-
interface LabeledStatement extends Node, HasSpan {
|
|
1877
|
-
type: "LabeledStatement";
|
|
1878
|
-
label: Identifier;
|
|
1879
|
-
body: Statement;
|
|
1880
|
-
}
|
|
1881
|
-
interface BreakStatement extends Node, HasSpan {
|
|
1882
|
-
type: "BreakStatement";
|
|
1883
|
-
label?: Identifier;
|
|
1884
|
-
}
|
|
1885
|
-
interface ContinueStatement extends Node, HasSpan {
|
|
1886
|
-
type: "ContinueStatement";
|
|
1887
|
-
label?: Identifier;
|
|
1888
|
-
}
|
|
1889
|
-
interface IfStatement extends Node, HasSpan {
|
|
1890
|
-
type: "IfStatement";
|
|
1891
|
-
test: Expression;
|
|
1892
|
-
consequent: Statement;
|
|
1893
|
-
alternate?: Statement;
|
|
1894
|
-
}
|
|
1895
|
-
interface SwitchStatement extends Node, HasSpan {
|
|
1896
|
-
type: "SwitchStatement";
|
|
1897
|
-
discriminant: Expression;
|
|
1898
|
-
cases: SwitchCase[];
|
|
1899
|
-
}
|
|
1900
|
-
interface ThrowStatement extends Node, HasSpan {
|
|
1901
|
-
type: "ThrowStatement";
|
|
1902
|
-
argument: Expression;
|
|
1903
|
-
}
|
|
1904
|
-
interface TryStatement extends Node, HasSpan {
|
|
1905
|
-
type: "TryStatement";
|
|
1906
|
-
block: BlockStatement;
|
|
1907
|
-
handler?: CatchClause;
|
|
1908
|
-
finalizer?: BlockStatement;
|
|
1909
|
-
}
|
|
1910
|
-
interface WhileStatement extends Node, HasSpan {
|
|
1911
|
-
type: "WhileStatement";
|
|
1912
|
-
test: Expression;
|
|
1913
|
-
body: Statement;
|
|
1914
|
-
}
|
|
1915
|
-
interface DoWhileStatement extends Node, HasSpan {
|
|
1916
|
-
type: "DoWhileStatement";
|
|
1917
|
-
test: Expression;
|
|
1918
|
-
body: Statement;
|
|
1919
|
-
}
|
|
1920
|
-
interface ForStatement extends Node, HasSpan {
|
|
1921
|
-
type: "ForStatement";
|
|
1922
|
-
init?: VariableDeclaration | Expression;
|
|
1923
|
-
test?: Expression;
|
|
1924
|
-
update?: Expression;
|
|
1925
|
-
body: Statement;
|
|
1926
|
-
}
|
|
1927
|
-
interface ForInStatement extends Node, HasSpan {
|
|
1928
|
-
type: "ForInStatement";
|
|
1929
|
-
left: VariableDeclaration | Pattern;
|
|
1930
|
-
right: Expression;
|
|
1931
|
-
body: Statement;
|
|
1932
|
-
}
|
|
1933
|
-
interface ForOfStatement extends Node, HasSpan {
|
|
1934
|
-
type: "ForOfStatement";
|
|
1935
|
-
/**
|
|
1936
|
-
* Span of the await token.
|
|
1937
|
-
*
|
|
1938
|
-
* es2018 for-await-of statements, e.g., `for await (const x of xs) {`
|
|
1939
|
-
*/
|
|
1940
|
-
await?: Span;
|
|
1941
|
-
left: VariableDeclaration | Pattern;
|
|
1942
|
-
right: Expression;
|
|
1943
|
-
body: Statement;
|
|
1944
|
-
}
|
|
1945
|
-
interface SwitchCase extends Node, HasSpan {
|
|
1946
|
-
type: "SwitchCase";
|
|
1947
|
-
/**
|
|
1948
|
-
* Undefined for default case
|
|
1949
|
-
*/
|
|
1950
|
-
test?: Expression;
|
|
1951
|
-
consequent: Statement[];
|
|
1952
|
-
}
|
|
1953
|
-
interface CatchClause extends Node, HasSpan {
|
|
1954
|
-
type: "CatchClause";
|
|
1955
|
-
/**
|
|
1956
|
-
* The param is `undefined` if the catch binding is omitted. E.g., `try { foo() } catch {}`
|
|
1957
|
-
*/
|
|
1958
|
-
param?: Pattern;
|
|
1959
|
-
body: BlockStatement;
|
|
1960
|
-
}
|
|
1961
|
-
interface TsTypeAnnotation extends Node, HasSpan {
|
|
1962
|
-
type: "TsTypeAnnotation";
|
|
1963
|
-
typeAnnotation: TsType;
|
|
1964
|
-
}
|
|
1965
|
-
interface TsTypeParameterDeclaration extends Node, HasSpan {
|
|
1966
|
-
type: "TsTypeParameterDeclaration";
|
|
1967
|
-
parameters: TsTypeParameter[];
|
|
1968
|
-
}
|
|
1969
|
-
interface TsTypeParameter extends Node, HasSpan {
|
|
1970
|
-
type: "TsTypeParameter";
|
|
1971
|
-
name: Identifier;
|
|
1972
|
-
in: boolean;
|
|
1973
|
-
out: boolean;
|
|
1974
|
-
constraint?: TsType;
|
|
1975
|
-
default?: TsType;
|
|
1976
|
-
}
|
|
1977
|
-
interface TsTypeParameterInstantiation extends Node, HasSpan {
|
|
1978
|
-
type: "TsTypeParameterInstantiation";
|
|
1979
|
-
params: TsType[];
|
|
1980
|
-
}
|
|
1981
|
-
interface TsParameterProperty extends Node, HasSpan, HasDecorator {
|
|
1982
|
-
type: "TsParameterProperty";
|
|
1983
|
-
accessibility?: Accessibility;
|
|
1984
|
-
override: boolean;
|
|
1985
|
-
readonly: boolean;
|
|
1986
|
-
param: TsParameterPropertyParameter;
|
|
1987
|
-
}
|
|
1988
|
-
type TsParameterPropertyParameter = BindingIdentifier | AssignmentPattern;
|
|
1989
|
-
interface TsQualifiedName extends Node {
|
|
1990
|
-
type: "TsQualifiedName";
|
|
1991
|
-
left: TsEntityName;
|
|
1992
|
-
right: Identifier;
|
|
1993
|
-
}
|
|
1994
|
-
type TsEntityName = TsQualifiedName | Identifier;
|
|
1995
|
-
type TsTypeElement = TsCallSignatureDeclaration | TsConstructSignatureDeclaration | TsPropertySignature | TsGetterSignature | TsSetterSignature | TsMethodSignature | TsIndexSignature;
|
|
1996
|
-
interface TsCallSignatureDeclaration extends Node, HasSpan {
|
|
1997
|
-
type: "TsCallSignatureDeclaration";
|
|
1998
|
-
params: TsFnParameter[];
|
|
1999
|
-
typeAnnotation?: TsTypeAnnotation;
|
|
2000
|
-
typeParams?: TsTypeParameterDeclaration;
|
|
2001
|
-
}
|
|
2002
|
-
interface TsConstructSignatureDeclaration extends Node, HasSpan {
|
|
2003
|
-
type: "TsConstructSignatureDeclaration";
|
|
2004
|
-
params: TsFnParameter[];
|
|
2005
|
-
typeAnnotation?: TsTypeAnnotation;
|
|
2006
|
-
typeParams?: TsTypeParameterDeclaration;
|
|
2007
|
-
}
|
|
2008
|
-
interface TsPropertySignature extends Node, HasSpan {
|
|
2009
|
-
type: "TsPropertySignature";
|
|
2010
|
-
readonly: boolean;
|
|
2011
|
-
key: Expression;
|
|
2012
|
-
computed: boolean;
|
|
2013
|
-
optional: boolean;
|
|
2014
|
-
typeAnnotation?: TsTypeAnnotation;
|
|
2015
|
-
}
|
|
2016
|
-
interface TsGetterSignature extends Node, HasSpan {
|
|
2017
|
-
type: "TsGetterSignature";
|
|
2018
|
-
readonly: boolean;
|
|
2019
|
-
key: Expression;
|
|
2020
|
-
computed: boolean;
|
|
2021
|
-
optional: boolean;
|
|
2022
|
-
typeAnnotation?: TsTypeAnnotation;
|
|
2023
|
-
}
|
|
2024
|
-
interface TsSetterSignature extends Node, HasSpan {
|
|
2025
|
-
type: "TsSetterSignature";
|
|
2026
|
-
readonly: boolean;
|
|
2027
|
-
key: Expression;
|
|
2028
|
-
computed: boolean;
|
|
2029
|
-
optional: boolean;
|
|
2030
|
-
param: TsFnParameter;
|
|
2031
|
-
}
|
|
2032
|
-
interface TsMethodSignature extends Node, HasSpan {
|
|
2033
|
-
type: "TsMethodSignature";
|
|
2034
|
-
readonly: boolean;
|
|
2035
|
-
key: Expression;
|
|
2036
|
-
computed: boolean;
|
|
2037
|
-
optional: boolean;
|
|
2038
|
-
params: TsFnParameter[];
|
|
2039
|
-
typeAnn?: TsTypeAnnotation;
|
|
2040
|
-
typeParams?: TsTypeParameterDeclaration;
|
|
2041
|
-
}
|
|
2042
|
-
interface TsIndexSignature extends Node, HasSpan {
|
|
2043
|
-
type: "TsIndexSignature";
|
|
2044
|
-
params: TsFnParameter[];
|
|
2045
|
-
typeAnnotation?: TsTypeAnnotation;
|
|
2046
|
-
readonly: boolean;
|
|
2047
|
-
static: boolean;
|
|
2048
|
-
}
|
|
2049
|
-
type TsType = TsKeywordType | TsThisType | TsFnOrConstructorType | TsTypeReference | TsTypeQuery | TsTypeLiteral | TsArrayType | TsTupleType | TsOptionalType | TsRestType | TsUnionOrIntersectionType | TsConditionalType | TsInferType | TsParenthesizedType | TsTypeOperator | TsIndexedAccessType | TsMappedType | TsLiteralType | TsTypePredicate | TsImportType;
|
|
2050
|
-
type TsFnOrConstructorType = TsFunctionType | TsConstructorType;
|
|
2051
|
-
interface TsKeywordType extends Node, HasSpan {
|
|
2052
|
-
type: "TsKeywordType";
|
|
2053
|
-
kind: TsKeywordTypeKind;
|
|
2054
|
-
}
|
|
2055
|
-
type TsKeywordTypeKind = "any" | "unknown" | "number" | "object" | "boolean" | "bigint" | "string" | "symbol" | "void" | "undefined" | "null" | "never" | "intrinsic";
|
|
2056
|
-
interface TsThisType extends Node, HasSpan {
|
|
2057
|
-
type: "TsThisType";
|
|
2058
|
-
}
|
|
2059
|
-
type TsFnParameter = BindingIdentifier | ArrayPattern | RestElement | ObjectPattern;
|
|
2060
|
-
interface TsFunctionType extends Node, HasSpan {
|
|
2061
|
-
type: "TsFunctionType";
|
|
2062
|
-
params: TsFnParameter[];
|
|
2063
|
-
typeParams?: TsTypeParameterDeclaration;
|
|
2064
|
-
typeAnnotation: TsTypeAnnotation;
|
|
2065
|
-
}
|
|
2066
|
-
interface TsConstructorType extends Node, HasSpan {
|
|
2067
|
-
type: "TsConstructorType";
|
|
2068
|
-
params: TsFnParameter[];
|
|
2069
|
-
typeParams?: TsTypeParameterDeclaration;
|
|
2070
|
-
typeAnnotation: TsTypeAnnotation;
|
|
2071
|
-
isAbstract: boolean;
|
|
2072
|
-
}
|
|
2073
|
-
interface TsTypeReference extends Node, HasSpan {
|
|
2074
|
-
type: "TsTypeReference";
|
|
2075
|
-
typeName: TsEntityName;
|
|
2076
|
-
typeParams?: TsTypeParameterInstantiation;
|
|
2077
|
-
}
|
|
2078
|
-
interface TsTypePredicate extends Node, HasSpan {
|
|
2079
|
-
type: "TsTypePredicate";
|
|
2080
|
-
asserts: boolean;
|
|
2081
|
-
paramName: TsThisTypeOrIdent;
|
|
2082
|
-
typeAnnotation?: TsTypeAnnotation;
|
|
2083
|
-
}
|
|
2084
|
-
type TsThisTypeOrIdent = TsThisType | Identifier;
|
|
2085
|
-
interface TsImportType extends Node, HasSpan {
|
|
2086
|
-
type: "TsImportType";
|
|
2087
|
-
argument: StringLiteral;
|
|
2088
|
-
qualifier?: TsEntityName;
|
|
2089
|
-
typeArguments?: TsTypeParameterInstantiation;
|
|
2090
|
-
}
|
|
2091
|
-
/**
|
|
2092
|
-
* `typeof` operator
|
|
2093
|
-
*/
|
|
2094
|
-
interface TsTypeQuery extends Node, HasSpan {
|
|
2095
|
-
type: "TsTypeQuery";
|
|
2096
|
-
exprName: TsTypeQueryExpr;
|
|
2097
|
-
typeArguments?: TsTypeParameterInstantiation;
|
|
2098
|
-
}
|
|
2099
|
-
type TsTypeQueryExpr = TsEntityName | TsImportType;
|
|
2100
|
-
interface TsTypeLiteral extends Node, HasSpan {
|
|
2101
|
-
type: "TsTypeLiteral";
|
|
2102
|
-
members: TsTypeElement[];
|
|
2103
|
-
}
|
|
2104
|
-
interface TsArrayType extends Node, HasSpan {
|
|
2105
|
-
type: "TsArrayType";
|
|
2106
|
-
elemType: TsType;
|
|
2107
|
-
}
|
|
2108
|
-
interface TsTupleType extends Node, HasSpan {
|
|
2109
|
-
type: "TsTupleType";
|
|
2110
|
-
elemTypes: TsTupleElement[];
|
|
2111
|
-
}
|
|
2112
|
-
interface TsTupleElement extends Node, HasSpan {
|
|
2113
|
-
type: "TsTupleElement";
|
|
2114
|
-
label?: Pattern;
|
|
2115
|
-
ty: TsType;
|
|
2116
|
-
}
|
|
2117
|
-
interface TsOptionalType extends Node, HasSpan {
|
|
2118
|
-
type: "TsOptionalType";
|
|
2119
|
-
typeAnnotation: TsType;
|
|
2120
|
-
}
|
|
2121
|
-
interface TsRestType extends Node, HasSpan {
|
|
2122
|
-
type: "TsRestType";
|
|
2123
|
-
typeAnnotation: TsType;
|
|
2124
|
-
}
|
|
2125
|
-
type TsUnionOrIntersectionType = TsUnionType | TsIntersectionType;
|
|
2126
|
-
interface TsUnionType extends Node, HasSpan {
|
|
2127
|
-
type: "TsUnionType";
|
|
2128
|
-
types: TsType[];
|
|
2129
|
-
}
|
|
2130
|
-
interface TsIntersectionType extends Node, HasSpan {
|
|
2131
|
-
type: "TsIntersectionType";
|
|
2132
|
-
types: TsType[];
|
|
2133
|
-
}
|
|
2134
|
-
interface TsConditionalType extends Node, HasSpan {
|
|
2135
|
-
type: "TsConditionalType";
|
|
2136
|
-
checkType: TsType;
|
|
2137
|
-
extendsType: TsType;
|
|
2138
|
-
trueType: TsType;
|
|
2139
|
-
falseType: TsType;
|
|
2140
|
-
}
|
|
2141
|
-
interface TsInferType extends Node, HasSpan {
|
|
2142
|
-
type: "TsInferType";
|
|
2143
|
-
typeParam: TsTypeParameter;
|
|
2144
|
-
}
|
|
2145
|
-
interface TsParenthesizedType extends Node, HasSpan {
|
|
2146
|
-
type: "TsParenthesizedType";
|
|
2147
|
-
typeAnnotation: TsType;
|
|
2148
|
-
}
|
|
2149
|
-
interface TsTypeOperator extends Node, HasSpan {
|
|
2150
|
-
type: "TsTypeOperator";
|
|
2151
|
-
op: TsTypeOperatorOp;
|
|
2152
|
-
typeAnnotation: TsType;
|
|
2153
|
-
}
|
|
2154
|
-
type TsTypeOperatorOp = "keyof" | "unique" | "readonly";
|
|
2155
|
-
interface TsIndexedAccessType extends Node, HasSpan {
|
|
2156
|
-
type: "TsIndexedAccessType";
|
|
2157
|
-
readonly: boolean;
|
|
2158
|
-
objectType: TsType;
|
|
2159
|
-
indexType: TsType;
|
|
2160
|
-
}
|
|
2161
|
-
type TruePlusMinus = true | "+" | "-";
|
|
2162
|
-
interface TsMappedType extends Node, HasSpan {
|
|
2163
|
-
type: "TsMappedType";
|
|
2164
|
-
readonly?: TruePlusMinus;
|
|
2165
|
-
typeParam: TsTypeParameter;
|
|
2166
|
-
nameType?: TsType;
|
|
2167
|
-
optional?: TruePlusMinus;
|
|
2168
|
-
typeAnnotation?: TsType;
|
|
2169
|
-
}
|
|
2170
|
-
interface TsLiteralType extends Node, HasSpan {
|
|
2171
|
-
type: "TsLiteralType";
|
|
2172
|
-
literal: TsLiteral;
|
|
2173
|
-
}
|
|
2174
|
-
type TsLiteral = NumericLiteral | StringLiteral | BooleanLiteral | BigIntLiteral | TsTemplateLiteralType;
|
|
2175
|
-
interface TsTemplateLiteralType extends Node, HasSpan {
|
|
2176
|
-
type: "TemplateLiteral";
|
|
2177
|
-
types: TsType[];
|
|
2178
|
-
quasis: TemplateElement[];
|
|
2179
|
-
}
|
|
2180
|
-
interface TsInterfaceDeclaration extends Node, HasSpan {
|
|
2181
|
-
type: "TsInterfaceDeclaration";
|
|
2182
|
-
id: Identifier;
|
|
2183
|
-
declare: boolean;
|
|
2184
|
-
typeParams?: TsTypeParameterDeclaration;
|
|
2185
|
-
extends: TsExpressionWithTypeArguments[];
|
|
2186
|
-
body: TsInterfaceBody;
|
|
2187
|
-
}
|
|
2188
|
-
interface TsInterfaceBody extends Node, HasSpan {
|
|
2189
|
-
type: "TsInterfaceBody";
|
|
2190
|
-
body: TsTypeElement[];
|
|
2191
|
-
}
|
|
2192
|
-
interface TsExpressionWithTypeArguments extends Node, HasSpan {
|
|
2193
|
-
type: "TsExpressionWithTypeArguments";
|
|
2194
|
-
expression: Expression;
|
|
2195
|
-
typeArguments?: TsTypeParameterInstantiation;
|
|
2196
|
-
}
|
|
2197
|
-
interface TsTypeAliasDeclaration extends Node, HasSpan {
|
|
2198
|
-
type: "TsTypeAliasDeclaration";
|
|
2199
|
-
declare: boolean;
|
|
2200
|
-
id: Identifier;
|
|
2201
|
-
typeParams?: TsTypeParameterDeclaration;
|
|
2202
|
-
typeAnnotation: TsType;
|
|
2203
|
-
}
|
|
2204
|
-
interface TsEnumDeclaration extends Node, HasSpan {
|
|
2205
|
-
type: "TsEnumDeclaration";
|
|
2206
|
-
declare: boolean;
|
|
2207
|
-
isConst: boolean;
|
|
2208
|
-
id: Identifier;
|
|
2209
|
-
members: TsEnumMember[];
|
|
2210
|
-
}
|
|
2211
|
-
interface TsEnumMember extends Node, HasSpan {
|
|
2212
|
-
type: "TsEnumMember";
|
|
2213
|
-
id: TsEnumMemberId;
|
|
2214
|
-
init?: Expression;
|
|
2215
|
-
}
|
|
2216
|
-
type TsEnumMemberId = Identifier | StringLiteral;
|
|
2217
|
-
interface TsModuleDeclaration extends Node, HasSpan {
|
|
2218
|
-
type: "TsModuleDeclaration";
|
|
2219
|
-
declare: boolean;
|
|
2220
|
-
global: boolean;
|
|
2221
|
-
id: TsModuleName;
|
|
2222
|
-
body?: TsNamespaceBody;
|
|
2223
|
-
}
|
|
2224
|
-
/**
|
|
2225
|
-
* `namespace A.B { }` is a namespace named `A` with another TsNamespaceDecl as its body.
|
|
2226
|
-
*/
|
|
2227
|
-
type TsNamespaceBody = TsModuleBlock | TsNamespaceDeclaration;
|
|
2228
|
-
interface TsModuleBlock extends Node, HasSpan {
|
|
2229
|
-
type: "TsModuleBlock";
|
|
2230
|
-
body: ModuleItem[];
|
|
2231
|
-
}
|
|
2232
|
-
interface TsNamespaceDeclaration extends Node, HasSpan {
|
|
2233
|
-
type: "TsNamespaceDeclaration";
|
|
2234
|
-
declare: boolean;
|
|
2235
|
-
global: boolean;
|
|
2236
|
-
id: Identifier;
|
|
2237
|
-
body: TsNamespaceBody;
|
|
2238
|
-
}
|
|
2239
|
-
type TsModuleName = Identifier | StringLiteral;
|
|
2240
|
-
interface TsImportEqualsDeclaration extends Node, HasSpan {
|
|
2241
|
-
type: "TsImportEqualsDeclaration";
|
|
2242
|
-
declare: boolean;
|
|
2243
|
-
isExport: boolean;
|
|
2244
|
-
isTypeOnly: boolean;
|
|
2245
|
-
id: Identifier;
|
|
2246
|
-
moduleRef: TsModuleReference;
|
|
2247
|
-
}
|
|
2248
|
-
type TsModuleReference = TsEntityName | TsExternalModuleReference;
|
|
2249
|
-
interface TsExternalModuleReference extends Node, HasSpan {
|
|
2250
|
-
type: "TsExternalModuleReference";
|
|
2251
|
-
expression: StringLiteral;
|
|
2252
|
-
}
|
|
2253
|
-
interface TsExportAssignment extends Node, HasSpan {
|
|
2254
|
-
type: "TsExportAssignment";
|
|
2255
|
-
expression: Expression;
|
|
2256
|
-
}
|
|
2257
|
-
interface TsNamespaceExportDeclaration extends Node, HasSpan {
|
|
2258
|
-
type: "TsNamespaceExportDeclaration";
|
|
2259
|
-
id: Identifier;
|
|
2260
|
-
}
|
|
2261
|
-
interface TsAsExpression extends ExpressionBase {
|
|
2262
|
-
type: "TsAsExpression";
|
|
2263
|
-
expression: Expression;
|
|
2264
|
-
typeAnnotation: TsType;
|
|
2265
|
-
}
|
|
2266
|
-
interface TsSatisfiesExpression extends ExpressionBase {
|
|
2267
|
-
type: "TsSatisfiesExpression";
|
|
2268
|
-
expression: Expression;
|
|
2269
|
-
typeAnnotation: TsType;
|
|
2270
|
-
}
|
|
2271
|
-
interface TsInstantiation extends Node, HasSpan {
|
|
2272
|
-
type: "TsInstantiation";
|
|
2273
|
-
expression: Expression;
|
|
2274
|
-
typeArguments: TsTypeParameterInstantiation;
|
|
2275
|
-
}
|
|
2276
|
-
interface TsTypeAssertion extends ExpressionBase {
|
|
2277
|
-
type: "TsTypeAssertion";
|
|
2278
|
-
expression: Expression;
|
|
2279
|
-
typeAnnotation: TsType;
|
|
2280
|
-
}
|
|
2281
|
-
interface TsConstAssertion extends ExpressionBase {
|
|
2282
|
-
type: "TsConstAssertion";
|
|
2283
|
-
expression: Expression;
|
|
2284
|
-
}
|
|
2285
|
-
interface TsNonNullExpression extends ExpressionBase {
|
|
2286
|
-
type: "TsNonNullExpression";
|
|
2287
|
-
expression: Expression;
|
|
2288
|
-
}
|
|
2289
|
-
type Accessibility = "public" | "protected" | "private";
|
|
2290
|
-
interface Invalid extends Node, HasSpan {
|
|
2291
|
-
type: "Invalid";
|
|
2292
|
-
}
|
|
2293
|
-
type WasmPlugin = [wasmPackage: string, config: Record<string, any>];
|
|
2294
|
-
|
|
2295
|
-
type SwcPluginConfig = Exclude<Options, "configFile" | "exclude" | "filename" | "sourceMaps" | "swcrc"> & {
|
|
2296
|
-
exclude?: FilterPattern;
|
|
2297
|
-
include?: FilterPattern;
|
|
2298
|
-
};
|
|
2299
|
-
|
|
2300
|
-
type PatchTypesOptions = {
|
|
2301
|
-
identifierReplacements?: Record<string, Record<string, string>>;
|
|
2302
|
-
};
|
|
2303
|
-
declare const patchTypescriptTypes: (options: PatchTypesOptions, logger: PailServerType) => Plugin$1;
|
|
2304
|
-
|
|
2305
|
-
declare global {
|
|
2306
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
2307
|
-
interface SymbolConstructor {
|
|
2308
|
-
readonly observable: symbol;
|
|
2309
|
-
}
|
|
2310
|
-
}
|
|
2311
|
-
|
|
2312
|
-
/**
|
|
2313
|
-
Extract all optional keys from the given type.
|
|
2314
|
-
|
|
2315
|
-
This is useful when you want to create a new type that contains different type values for the optional keys only.
|
|
2316
|
-
|
|
2317
|
-
@example
|
|
2318
|
-
```
|
|
2319
|
-
import type {OptionalKeysOf, Except} from 'type-fest';
|
|
2320
|
-
|
|
2321
|
-
interface User {
|
|
2322
|
-
name: string;
|
|
2323
|
-
surname: string;
|
|
2324
|
-
|
|
2325
|
-
luckyNumber?: number;
|
|
2326
|
-
}
|
|
2327
|
-
|
|
2328
|
-
const REMOVE_FIELD = Symbol('remove field symbol');
|
|
2329
|
-
type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
|
|
2330
|
-
[Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
|
|
2331
|
-
};
|
|
2332
|
-
|
|
2333
|
-
const update1: UpdateOperation<User> = {
|
|
2334
|
-
name: 'Alice'
|
|
2335
|
-
};
|
|
2336
|
-
|
|
2337
|
-
const update2: UpdateOperation<User> = {
|
|
2338
|
-
name: 'Bob',
|
|
2339
|
-
luckyNumber: REMOVE_FIELD
|
|
2340
|
-
};
|
|
2341
|
-
```
|
|
2342
|
-
|
|
2343
|
-
@category Utilities
|
|
2344
|
-
*/
|
|
2345
|
-
type OptionalKeysOf<BaseType extends object> =
|
|
2346
|
-
BaseType extends unknown // For distributing `BaseType`
|
|
2347
|
-
? (keyof {
|
|
2348
|
-
[Key in keyof BaseType as BaseType extends Record<Key, BaseType[Key]> ? never : Key]: never
|
|
2349
|
-
}) & (keyof BaseType) // Intersect with `keyof BaseType` to ensure result of `OptionalKeysOf<BaseType>` is always assignable to `keyof BaseType`
|
|
2350
|
-
: never; // Should never happen
|
|
2351
|
-
|
|
2352
|
-
/**
|
|
2353
|
-
Extract all required keys from the given type.
|
|
2354
|
-
|
|
2355
|
-
This is useful when you want to create a new type that contains different type values for the required keys only or use the list of keys for validation purposes, etc...
|
|
2356
|
-
|
|
2357
|
-
@example
|
|
2358
|
-
```
|
|
2359
|
-
import type {RequiredKeysOf} from 'type-fest';
|
|
2360
|
-
|
|
2361
|
-
declare function createValidation<Entity extends object, Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>>(field: Key, validator: (value: Entity[Key]) => boolean): ValidatorFn;
|
|
2362
|
-
|
|
2363
|
-
interface User {
|
|
2364
|
-
name: string;
|
|
2365
|
-
surname: string;
|
|
2366
|
-
|
|
2367
|
-
luckyNumber?: number;
|
|
2368
|
-
}
|
|
2369
|
-
|
|
2370
|
-
const validator1 = createValidation<User>('name', value => value.length < 25);
|
|
2371
|
-
const validator2 = createValidation<User>('surname', value => value.length < 25);
|
|
2372
|
-
```
|
|
2373
|
-
|
|
2374
|
-
@category Utilities
|
|
2375
|
-
*/
|
|
2376
|
-
type RequiredKeysOf<BaseType extends object> =
|
|
2377
|
-
BaseType extends unknown // For distributing `BaseType`
|
|
2378
|
-
? Exclude<keyof BaseType, OptionalKeysOf<BaseType>>
|
|
2379
|
-
: never; // Should never happen
|
|
2380
|
-
|
|
2381
|
-
/**
|
|
2382
|
-
Returns a boolean for whether the given type is `never`.
|
|
2383
|
-
|
|
2384
|
-
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
|
|
2385
|
-
@link https://stackoverflow.com/a/53984913/10292952
|
|
2386
|
-
@link https://www.zhenghao.io/posts/ts-never
|
|
2387
|
-
|
|
2388
|
-
Useful in type utilities, such as checking if something does not occur.
|
|
2389
|
-
|
|
2390
|
-
@example
|
|
2391
|
-
```
|
|
2392
|
-
import type {IsNever, And} from 'type-fest';
|
|
2393
|
-
|
|
2394
|
-
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
|
|
2395
|
-
type AreStringsEqual<A extends string, B extends string> =
|
|
2396
|
-
And<
|
|
2397
|
-
IsNever<Exclude<A, B>> extends true ? true : false,
|
|
2398
|
-
IsNever<Exclude<B, A>> extends true ? true : false
|
|
2399
|
-
>;
|
|
2400
|
-
|
|
2401
|
-
type EndIfEqual<I extends string, O extends string> =
|
|
2402
|
-
AreStringsEqual<I, O> extends true
|
|
2403
|
-
? never
|
|
2404
|
-
: void;
|
|
2405
|
-
|
|
2406
|
-
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
|
|
2407
|
-
if (input === output) {
|
|
2408
|
-
process.exit(0);
|
|
2409
|
-
}
|
|
2410
|
-
}
|
|
2411
|
-
|
|
2412
|
-
endIfEqual('abc', 'abc');
|
|
2413
|
-
//=> never
|
|
2414
|
-
|
|
2415
|
-
endIfEqual('abc', '123');
|
|
2416
|
-
//=> void
|
|
2417
|
-
```
|
|
2418
|
-
|
|
2419
|
-
@category Type Guard
|
|
2420
|
-
@category Utilities
|
|
2421
|
-
*/
|
|
2422
|
-
type IsNever<T> = [T] extends [never] ? true : false;
|
|
2423
|
-
|
|
2424
|
-
/**
|
|
2425
|
-
An if-else-like type that resolves depending on whether the given type is `never`.
|
|
2426
|
-
|
|
2427
|
-
@see {@link IsNever}
|
|
2428
|
-
|
|
2429
|
-
@example
|
|
2430
|
-
```
|
|
2431
|
-
import type {IfNever} from 'type-fest';
|
|
2432
|
-
|
|
2433
|
-
type ShouldBeTrue = IfNever<never>;
|
|
2434
|
-
//=> true
|
|
2435
|
-
|
|
2436
|
-
type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
|
|
2437
|
-
//=> 'bar'
|
|
2438
|
-
```
|
|
2439
|
-
|
|
2440
|
-
@category Type Guard
|
|
2441
|
-
@category Utilities
|
|
2442
|
-
*/
|
|
2443
|
-
type IfNever<T, TypeIfNever = true, TypeIfNotNever = false> = (
|
|
2444
|
-
IsNever<T> extends true ? TypeIfNever : TypeIfNotNever
|
|
2445
|
-
);
|
|
2446
|
-
|
|
2447
|
-
// Can eventually be replaced with the built-in once this library supports
|
|
2448
|
-
// TS5.4+ only. Tracked in https://github.com/sindresorhus/type-fest/issues/848
|
|
2449
|
-
type NoInfer<T> = T extends infer U ? U : never;
|
|
2450
|
-
|
|
2451
|
-
/**
|
|
2452
|
-
Returns a boolean for whether the given type is `any`.
|
|
2453
|
-
|
|
2454
|
-
@link https://stackoverflow.com/a/49928360/1490091
|
|
2455
|
-
|
|
2456
|
-
Useful in type utilities, such as disallowing `any`s to be passed to a function.
|
|
2457
|
-
|
|
2458
|
-
@example
|
|
2459
|
-
```
|
|
2460
|
-
import type {IsAny} from 'type-fest';
|
|
2461
|
-
|
|
2462
|
-
const typedObject = {a: 1, b: 2} as const;
|
|
2463
|
-
const anyObject: any = {a: 1, b: 2};
|
|
2464
|
-
|
|
2465
|
-
function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(obj: O, key: K) {
|
|
2466
|
-
return obj[key];
|
|
2467
|
-
}
|
|
2468
|
-
|
|
2469
|
-
const typedA = get(typedObject, 'a');
|
|
2470
|
-
//=> 1
|
|
2471
|
-
|
|
2472
|
-
const anyA = get(anyObject, 'a');
|
|
2473
|
-
//=> any
|
|
2474
|
-
```
|
|
2475
|
-
|
|
2476
|
-
@category Type Guard
|
|
2477
|
-
@category Utilities
|
|
2478
|
-
*/
|
|
2479
|
-
type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
|
2480
|
-
|
|
2481
|
-
/**
|
|
2482
|
-
Returns a boolean for whether the two given types are equal.
|
|
2483
|
-
|
|
2484
|
-
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
2485
|
-
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
2486
|
-
|
|
2487
|
-
Use-cases:
|
|
2488
|
-
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
2489
|
-
|
|
2490
|
-
@example
|
|
2491
|
-
```
|
|
2492
|
-
import type {IsEqual} from 'type-fest';
|
|
2493
|
-
|
|
2494
|
-
// This type returns a boolean for whether the given array includes the given item.
|
|
2495
|
-
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
2496
|
-
type Includes<Value extends readonly any[], Item> =
|
|
2497
|
-
Value extends readonly [Value[0], ...infer rest]
|
|
2498
|
-
? IsEqual<Value[0], Item> extends true
|
|
2499
|
-
? true
|
|
2500
|
-
: Includes<rest, Item>
|
|
2501
|
-
: false;
|
|
2502
|
-
```
|
|
2503
|
-
|
|
2504
|
-
@category Type Guard
|
|
2505
|
-
@category Utilities
|
|
2506
|
-
*/
|
|
2507
|
-
type IsEqual<A, B> =
|
|
2508
|
-
(<G>() => G extends A & G | G ? 1 : 2) extends
|
|
2509
|
-
(<G>() => G extends B & G | G ? 1 : 2)
|
|
2510
|
-
? true
|
|
2511
|
-
: false;
|
|
2512
|
-
|
|
2513
|
-
/**
|
|
2514
|
-
Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
|
|
2515
|
-
|
|
2516
|
-
@example
|
|
2517
|
-
```
|
|
2518
|
-
import type {Simplify} from 'type-fest';
|
|
2519
|
-
|
|
2520
|
-
type PositionProps = {
|
|
2521
|
-
top: number;
|
|
2522
|
-
left: number;
|
|
2523
|
-
};
|
|
2524
|
-
|
|
2525
|
-
type SizeProps = {
|
|
2526
|
-
width: number;
|
|
2527
|
-
height: number;
|
|
2528
|
-
};
|
|
2529
|
-
|
|
2530
|
-
// In your editor, hovering over `Props` will show a flattened object with all the properties.
|
|
2531
|
-
type Props = Simplify<PositionProps & SizeProps>;
|
|
2532
|
-
```
|
|
2533
|
-
|
|
2534
|
-
Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
|
|
2535
|
-
|
|
2536
|
-
If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
|
|
2537
|
-
|
|
2538
|
-
@example
|
|
2539
|
-
```
|
|
2540
|
-
import type {Simplify} from 'type-fest';
|
|
2541
|
-
|
|
2542
|
-
interface SomeInterface {
|
|
2543
|
-
foo: number;
|
|
2544
|
-
bar?: string;
|
|
2545
|
-
baz: number | undefined;
|
|
2546
|
-
}
|
|
2547
|
-
|
|
2548
|
-
type SomeType = {
|
|
2549
|
-
foo: number;
|
|
2550
|
-
bar?: string;
|
|
2551
|
-
baz: number | undefined;
|
|
2552
|
-
};
|
|
2553
|
-
|
|
2554
|
-
const literal = {foo: 123, bar: 'hello', baz: 456};
|
|
2555
|
-
const someType: SomeType = literal;
|
|
2556
|
-
const someInterface: SomeInterface = literal;
|
|
2557
|
-
|
|
2558
|
-
function fn(object: Record<string, unknown>): void {}
|
|
2559
|
-
|
|
2560
|
-
fn(literal); // Good: literal object type is sealed
|
|
2561
|
-
fn(someType); // Good: type is sealed
|
|
2562
|
-
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
|
|
2563
|
-
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
|
|
2564
|
-
```
|
|
2565
|
-
|
|
2566
|
-
@link https://github.com/microsoft/TypeScript/issues/15300
|
|
2567
|
-
@see SimplifyDeep
|
|
2568
|
-
@category Object
|
|
2569
|
-
*/
|
|
2570
|
-
type Simplify<T> = {[KeyType in keyof T]: T[KeyType]} & {};
|
|
2571
|
-
|
|
2572
|
-
/**
|
|
2573
|
-
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
2574
|
-
|
|
2575
|
-
This is the counterpart of `PickIndexSignature`.
|
|
2576
|
-
|
|
2577
|
-
Use-cases:
|
|
2578
|
-
- Remove overly permissive signatures from third-party types.
|
|
2579
|
-
|
|
2580
|
-
This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
|
|
2581
|
-
|
|
2582
|
-
It relies on the fact that an empty object (`{}`) is assignable to an object with just an index signature, like `Record<string, unknown>`, but not to an object with explicitly defined keys, like `Record<'foo' | 'bar', unknown>`.
|
|
2583
|
-
|
|
2584
|
-
(The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
|
|
2585
|
-
|
|
2586
|
-
```
|
|
2587
|
-
const indexed: Record<string, unknown> = {}; // Allowed
|
|
2588
|
-
|
|
2589
|
-
const keyed: Record<'foo', unknown> = {}; // Error
|
|
2590
|
-
// => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
|
|
2591
|
-
```
|
|
2592
|
-
|
|
2593
|
-
Instead of causing a type error like the above, you can also use a [conditional type](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to test whether a type is assignable to another:
|
|
2594
|
-
|
|
2595
|
-
```
|
|
2596
|
-
type Indexed = {} extends Record<string, unknown>
|
|
2597
|
-
? '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
2598
|
-
: '❌ `{}` is NOT assignable to `Record<string, unknown>`';
|
|
2599
|
-
// => '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
2600
|
-
|
|
2601
|
-
type Keyed = {} extends Record<'foo' | 'bar', unknown>
|
|
2602
|
-
? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
|
|
2603
|
-
: "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
|
|
2604
|
-
// => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
|
|
2605
|
-
```
|
|
2606
|
-
|
|
2607
|
-
Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
|
|
2608
|
-
|
|
2609
|
-
```
|
|
2610
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
2611
|
-
|
|
2612
|
-
type OmitIndexSignature<ObjectType> = {
|
|
2613
|
-
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
|
2614
|
-
]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
|
|
2615
|
-
};
|
|
2616
|
-
```
|
|
2617
|
-
|
|
2618
|
-
...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
|
|
2619
|
-
|
|
2620
|
-
```
|
|
2621
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
2622
|
-
|
|
2623
|
-
type OmitIndexSignature<ObjectType> = {
|
|
2624
|
-
[KeyType in keyof ObjectType
|
|
2625
|
-
// Is `{}` assignable to `Record<KeyType, unknown>`?
|
|
2626
|
-
as {} extends Record<KeyType, unknown>
|
|
2627
|
-
? ... // ✅ `{}` is assignable to `Record<KeyType, unknown>`
|
|
2628
|
-
: ... // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
|
|
2629
|
-
]: ObjectType[KeyType];
|
|
2630
|
-
};
|
|
2631
|
-
```
|
|
2632
|
-
|
|
2633
|
-
If `{}` is assignable, it means that `KeyType` is an index signature and we want to remove it. If it is not assignable, `KeyType` is a "real" key and we want to keep it.
|
|
2634
|
-
|
|
2635
|
-
@example
|
|
2636
|
-
```
|
|
2637
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
2638
|
-
|
|
2639
|
-
interface Example {
|
|
2640
|
-
// These index signatures will be removed.
|
|
2641
|
-
[x: string]: any
|
|
2642
|
-
[x: number]: any
|
|
2643
|
-
[x: symbol]: any
|
|
2644
|
-
[x: `head-${string}`]: string
|
|
2645
|
-
[x: `${string}-tail`]: string
|
|
2646
|
-
[x: `head-${string}-tail`]: string
|
|
2647
|
-
[x: `${bigint}`]: string
|
|
2648
|
-
[x: `embedded-${number}`]: string
|
|
2649
|
-
|
|
2650
|
-
// These explicitly defined keys will remain.
|
|
2651
|
-
foo: 'bar';
|
|
2652
|
-
qux?: 'baz';
|
|
2653
|
-
}
|
|
2654
|
-
|
|
2655
|
-
type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
2656
|
-
// => { foo: 'bar'; qux?: 'baz' | undefined; }
|
|
2657
|
-
```
|
|
2658
|
-
|
|
2659
|
-
@see PickIndexSignature
|
|
2660
|
-
@category Object
|
|
2661
|
-
*/
|
|
2662
|
-
type OmitIndexSignature<ObjectType> = {
|
|
2663
|
-
[KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
|
|
2664
|
-
? never
|
|
2665
|
-
: KeyType]: ObjectType[KeyType];
|
|
2666
|
-
};
|
|
2667
|
-
|
|
2668
|
-
/**
|
|
2669
|
-
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
2670
|
-
|
|
2671
|
-
This is the counterpart of `OmitIndexSignature`.
|
|
2672
|
-
|
|
2673
|
-
@example
|
|
2674
|
-
```
|
|
2675
|
-
import type {PickIndexSignature} from 'type-fest';
|
|
2676
|
-
|
|
2677
|
-
declare const symbolKey: unique symbol;
|
|
2678
|
-
|
|
2679
|
-
type Example = {
|
|
2680
|
-
// These index signatures will remain.
|
|
2681
|
-
[x: string]: unknown;
|
|
2682
|
-
[x: number]: unknown;
|
|
2683
|
-
[x: symbol]: unknown;
|
|
2684
|
-
[x: `head-${string}`]: string;
|
|
2685
|
-
[x: `${string}-tail`]: string;
|
|
2686
|
-
[x: `head-${string}-tail`]: string;
|
|
2687
|
-
[x: `${bigint}`]: string;
|
|
2688
|
-
[x: `embedded-${number}`]: string;
|
|
2689
|
-
|
|
2690
|
-
// These explicitly defined keys will be removed.
|
|
2691
|
-
['kebab-case-key']: string;
|
|
2692
|
-
[symbolKey]: string;
|
|
2693
|
-
foo: 'bar';
|
|
2694
|
-
qux?: 'baz';
|
|
2695
|
-
};
|
|
2696
|
-
|
|
2697
|
-
type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
2698
|
-
// {
|
|
2699
|
-
// [x: string]: unknown;
|
|
2700
|
-
// [x: number]: unknown;
|
|
2701
|
-
// [x: symbol]: unknown;
|
|
2702
|
-
// [x: `head-${string}`]: string;
|
|
2703
|
-
// [x: `${string}-tail`]: string;
|
|
2704
|
-
// [x: `head-${string}-tail`]: string;
|
|
2705
|
-
// [x: `${bigint}`]: string;
|
|
2706
|
-
// [x: `embedded-${number}`]: string;
|
|
2707
|
-
// }
|
|
2708
|
-
```
|
|
2709
|
-
|
|
2710
|
-
@see OmitIndexSignature
|
|
2711
|
-
@category Object
|
|
2712
|
-
*/
|
|
2713
|
-
type PickIndexSignature<ObjectType> = {
|
|
2714
|
-
[KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
|
|
2715
|
-
? KeyType
|
|
2716
|
-
: never]: ObjectType[KeyType];
|
|
2717
|
-
};
|
|
2718
|
-
|
|
2719
|
-
// Merges two objects without worrying about index signatures.
|
|
2720
|
-
type SimpleMerge<Destination, Source> = {
|
|
2721
|
-
[Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key];
|
|
2722
|
-
} & Source;
|
|
2723
|
-
|
|
2724
|
-
/**
|
|
2725
|
-
Merge two types into a new type. Keys of the second type overrides keys of the first type.
|
|
2726
|
-
|
|
2727
|
-
@example
|
|
2728
|
-
```
|
|
2729
|
-
import type {Merge} from 'type-fest';
|
|
2730
|
-
|
|
2731
|
-
interface Foo {
|
|
2732
|
-
[x: string]: unknown;
|
|
2733
|
-
[x: number]: unknown;
|
|
2734
|
-
foo: string;
|
|
2735
|
-
bar: symbol;
|
|
2736
|
-
}
|
|
2737
|
-
|
|
2738
|
-
type Bar = {
|
|
2739
|
-
[x: number]: number;
|
|
2740
|
-
[x: symbol]: unknown;
|
|
2741
|
-
bar: Date;
|
|
2742
|
-
baz: boolean;
|
|
2743
|
-
};
|
|
2744
|
-
|
|
2745
|
-
export type FooBar = Merge<Foo, Bar>;
|
|
2746
|
-
// => {
|
|
2747
|
-
// [x: string]: unknown;
|
|
2748
|
-
// [x: number]: number;
|
|
2749
|
-
// [x: symbol]: unknown;
|
|
2750
|
-
// foo: string;
|
|
2751
|
-
// bar: Date;
|
|
2752
|
-
// baz: boolean;
|
|
2753
|
-
// }
|
|
2754
|
-
```
|
|
2755
|
-
|
|
2756
|
-
@category Object
|
|
2757
|
-
*/
|
|
2758
|
-
type Merge<Destination, Source> =
|
|
2759
|
-
Simplify<
|
|
2760
|
-
SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>>
|
|
2761
|
-
& SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>
|
|
2762
|
-
>;
|
|
2763
|
-
|
|
2764
|
-
/**
|
|
2765
|
-
An if-else-like type that resolves depending on whether the given type is `any`.
|
|
2766
|
-
|
|
2767
|
-
@see {@link IsAny}
|
|
2768
|
-
|
|
2769
|
-
@example
|
|
2770
|
-
```
|
|
2771
|
-
import type {IfAny} from 'type-fest';
|
|
2772
|
-
|
|
2773
|
-
type ShouldBeTrue = IfAny<any>;
|
|
2774
|
-
//=> true
|
|
2775
|
-
|
|
2776
|
-
type ShouldBeBar = IfAny<'not any', 'foo', 'bar'>;
|
|
2777
|
-
//=> 'bar'
|
|
2778
|
-
```
|
|
2779
|
-
|
|
2780
|
-
@category Type Guard
|
|
2781
|
-
@category Utilities
|
|
2782
|
-
*/
|
|
2783
|
-
type IfAny<T, TypeIfAny = true, TypeIfNotAny = false> = (
|
|
2784
|
-
IsAny<T> extends true ? TypeIfAny : TypeIfNotAny
|
|
2785
|
-
);
|
|
2786
|
-
|
|
2787
|
-
/**
|
|
2788
|
-
Merges user specified options with default options.
|
|
2789
|
-
|
|
2790
|
-
@example
|
|
2791
|
-
```
|
|
2792
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
2793
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
|
|
2794
|
-
type SpecifiedOptions = {leavesOnly: true};
|
|
2795
|
-
|
|
2796
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
2797
|
-
//=> {maxRecursionDepth: 10; leavesOnly: true}
|
|
2798
|
-
```
|
|
2799
|
-
|
|
2800
|
-
@example
|
|
2801
|
-
```
|
|
2802
|
-
// Complains if default values are not provided for optional options
|
|
2803
|
-
|
|
2804
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
2805
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10};
|
|
2806
|
-
type SpecifiedOptions = {};
|
|
2807
|
-
|
|
2808
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
2809
|
-
// ~~~~~~~~~~~~~~~~~~~
|
|
2810
|
-
// Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
|
|
2811
|
-
```
|
|
2812
|
-
|
|
2813
|
-
@example
|
|
2814
|
-
```
|
|
2815
|
-
// Complains if an option's default type does not conform to the expected type
|
|
2816
|
-
|
|
2817
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
2818
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
|
|
2819
|
-
type SpecifiedOptions = {};
|
|
2820
|
-
|
|
2821
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
2822
|
-
// ~~~~~~~~~~~~~~~~~~~
|
|
2823
|
-
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
2824
|
-
```
|
|
2825
|
-
|
|
2826
|
-
@example
|
|
2827
|
-
```
|
|
2828
|
-
// Complains if an option's specified type does not conform to the expected type
|
|
2829
|
-
|
|
2830
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
2831
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
|
|
2832
|
-
type SpecifiedOptions = {leavesOnly: 'yes'};
|
|
2833
|
-
|
|
2834
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
2835
|
-
// ~~~~~~~~~~~~~~~~
|
|
2836
|
-
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
2837
|
-
```
|
|
2838
|
-
*/
|
|
2839
|
-
type ApplyDefaultOptions<
|
|
2840
|
-
Options extends object,
|
|
2841
|
-
Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>,
|
|
2842
|
-
SpecifiedOptions extends Options,
|
|
2843
|
-
> =
|
|
2844
|
-
IfAny<SpecifiedOptions, Defaults,
|
|
2845
|
-
IfNever<SpecifiedOptions, Defaults,
|
|
2846
|
-
Simplify<Merge<Defaults, {
|
|
2847
|
-
[Key in keyof SpecifiedOptions
|
|
2848
|
-
as Key extends OptionalKeysOf<Options>
|
|
2849
|
-
? Extract<SpecifiedOptions[Key], undefined> extends never
|
|
2850
|
-
? Key
|
|
2851
|
-
: never
|
|
2852
|
-
: Key
|
|
2853
|
-
]: SpecifiedOptions[Key]
|
|
2854
|
-
}> & Required<Options>> // `& Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
|
|
2855
|
-
>>;
|
|
2856
|
-
|
|
2857
|
-
/**
|
|
2858
|
-
Filter out keys from an object.
|
|
2859
|
-
|
|
2860
|
-
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
2861
|
-
Returns `never` if `Key` extends `Exclude`.
|
|
2862
|
-
Returns `Key` otherwise.
|
|
2863
|
-
|
|
2864
|
-
@example
|
|
2865
|
-
```
|
|
2866
|
-
type Filtered = Filter<'foo', 'foo'>;
|
|
2867
|
-
//=> never
|
|
2868
|
-
```
|
|
2869
|
-
|
|
2870
|
-
@example
|
|
2871
|
-
```
|
|
2872
|
-
type Filtered = Filter<'bar', string>;
|
|
2873
|
-
//=> never
|
|
2874
|
-
```
|
|
2875
|
-
|
|
2876
|
-
@example
|
|
2877
|
-
```
|
|
2878
|
-
type Filtered = Filter<'bar', 'foo'>;
|
|
2879
|
-
//=> 'bar'
|
|
2880
|
-
```
|
|
2881
|
-
|
|
2882
|
-
@see {Except}
|
|
2883
|
-
*/
|
|
2884
|
-
type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
2885
|
-
|
|
2886
|
-
type ExceptOptions = {
|
|
2887
|
-
/**
|
|
2888
|
-
Disallow assigning non-specified properties.
|
|
2889
|
-
|
|
2890
|
-
Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
|
|
2891
|
-
|
|
2892
|
-
@default false
|
|
2893
|
-
*/
|
|
2894
|
-
requireExactProps?: boolean;
|
|
2895
|
-
};
|
|
2896
|
-
|
|
2897
|
-
type DefaultExceptOptions = {
|
|
2898
|
-
requireExactProps: false;
|
|
2899
|
-
};
|
|
2900
|
-
|
|
2901
|
-
/**
|
|
2902
|
-
Create a type from an object type without certain keys.
|
|
2903
|
-
|
|
2904
|
-
We recommend setting the `requireExactProps` option to `true`.
|
|
2905
|
-
|
|
2906
|
-
This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.
|
|
2907
|
-
|
|
2908
|
-
This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).
|
|
2909
|
-
|
|
2910
|
-
@example
|
|
2911
|
-
```
|
|
2912
|
-
import type {Except} from 'type-fest';
|
|
2913
|
-
|
|
2914
|
-
type Foo = {
|
|
2915
|
-
a: number;
|
|
2916
|
-
b: string;
|
|
2917
|
-
};
|
|
2918
|
-
|
|
2919
|
-
type FooWithoutA = Except<Foo, 'a'>;
|
|
2920
|
-
//=> {b: string}
|
|
2921
|
-
|
|
2922
|
-
const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
|
|
2923
|
-
//=> errors: 'a' does not exist in type '{ b: string; }'
|
|
2924
|
-
|
|
2925
|
-
type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
|
|
2926
|
-
//=> {a: number} & Partial<Record<"b", never>>
|
|
2927
|
-
|
|
2928
|
-
const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
|
|
2929
|
-
//=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
|
|
2930
|
-
|
|
2931
|
-
// The `Omit` utility type doesn't work when omitting specific keys from objects containing index signatures.
|
|
2932
|
-
|
|
2933
|
-
// Consider the following example:
|
|
2934
|
-
|
|
2935
|
-
type UserData = {
|
|
2936
|
-
[metadata: string]: string;
|
|
2937
|
-
email: string;
|
|
2938
|
-
name: string;
|
|
2939
|
-
role: 'admin' | 'user';
|
|
2940
|
-
};
|
|
2941
|
-
|
|
2942
|
-
// `Omit` clearly doesn't behave as expected in this case:
|
|
2943
|
-
type PostPayload = Omit<UserData, 'email'>;
|
|
2944
|
-
//=> type PostPayload = { [x: string]: string; [x: number]: string; }
|
|
2945
|
-
|
|
2946
|
-
// In situations like this, `Except` works better.
|
|
2947
|
-
// It simply removes the `email` key while preserving all the other keys.
|
|
2948
|
-
type PostPayload = Except<UserData, 'email'>;
|
|
2949
|
-
//=> type PostPayload = { [x: string]: string; name: string; role: 'admin' | 'user'; }
|
|
2950
|
-
```
|
|
2951
|
-
|
|
2952
|
-
@category Object
|
|
2953
|
-
*/
|
|
2954
|
-
type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> =
|
|
2955
|
-
_Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
|
|
2956
|
-
|
|
2957
|
-
type _Except<ObjectType, KeysType extends keyof ObjectType, Options extends Required<ExceptOptions>> = {
|
|
2958
|
-
[KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
|
|
2959
|
-
} & (Options['requireExactProps'] extends true
|
|
2960
|
-
? Partial<Record<KeysType, never>>
|
|
2961
|
-
: {});
|
|
2962
|
-
|
|
2963
|
-
declare namespace TsConfigJson {
|
|
2964
|
-
namespace CompilerOptions {
|
|
2965
|
-
export type JSX =
|
|
2966
|
-
| 'preserve'
|
|
2967
|
-
| 'react'
|
|
2968
|
-
| 'react-jsx'
|
|
2969
|
-
| 'react-jsxdev'
|
|
2970
|
-
| 'react-native';
|
|
2971
|
-
|
|
2972
|
-
export type Module =
|
|
2973
|
-
| 'CommonJS'
|
|
2974
|
-
| 'AMD'
|
|
2975
|
-
| 'System'
|
|
2976
|
-
| 'UMD'
|
|
2977
|
-
| 'ES6'
|
|
2978
|
-
| 'ES2015'
|
|
2979
|
-
| 'ES2020'
|
|
2980
|
-
| 'ES2022'
|
|
2981
|
-
| 'ESNext'
|
|
2982
|
-
| 'Node16'
|
|
2983
|
-
| 'Node18'
|
|
2984
|
-
| 'NodeNext'
|
|
2985
|
-
| 'Preserve'
|
|
2986
|
-
| 'None'
|
|
2987
|
-
// Lowercase alternatives
|
|
2988
|
-
| 'commonjs'
|
|
2989
|
-
| 'amd'
|
|
2990
|
-
| 'system'
|
|
2991
|
-
| 'umd'
|
|
2992
|
-
| 'es6'
|
|
2993
|
-
| 'es2015'
|
|
2994
|
-
| 'es2020'
|
|
2995
|
-
| 'es2022'
|
|
2996
|
-
| 'esnext'
|
|
2997
|
-
| 'node16'
|
|
2998
|
-
| 'node18'
|
|
2999
|
-
| 'nodenext'
|
|
3000
|
-
| 'preserve'
|
|
3001
|
-
| 'none';
|
|
3002
|
-
|
|
3003
|
-
export type NewLine =
|
|
3004
|
-
| 'CRLF'
|
|
3005
|
-
| 'LF'
|
|
3006
|
-
// Lowercase alternatives
|
|
3007
|
-
| 'crlf'
|
|
3008
|
-
| 'lf';
|
|
3009
|
-
|
|
3010
|
-
export type Target =
|
|
3011
|
-
| 'ES3'
|
|
3012
|
-
| 'ES5'
|
|
3013
|
-
| 'ES6'
|
|
3014
|
-
| 'ES2015'
|
|
3015
|
-
| 'ES2016'
|
|
3016
|
-
| 'ES2017'
|
|
3017
|
-
| 'ES2018'
|
|
3018
|
-
| 'ES2019'
|
|
3019
|
-
| 'ES2020'
|
|
3020
|
-
| 'ES2021'
|
|
3021
|
-
| 'ES2022'
|
|
3022
|
-
| 'ES2023'
|
|
3023
|
-
| 'ES2024'
|
|
3024
|
-
| 'ESNext'
|
|
3025
|
-
// Lowercase alternatives
|
|
3026
|
-
| 'es3'
|
|
3027
|
-
| 'es5'
|
|
3028
|
-
| 'es6'
|
|
3029
|
-
| 'es2015'
|
|
3030
|
-
| 'es2016'
|
|
3031
|
-
| 'es2017'
|
|
3032
|
-
| 'es2018'
|
|
3033
|
-
| 'es2019'
|
|
3034
|
-
| 'es2020'
|
|
3035
|
-
| 'es2021'
|
|
3036
|
-
| 'es2022'
|
|
3037
|
-
| 'es2023'
|
|
3038
|
-
| 'es2024'
|
|
3039
|
-
| 'esnext';
|
|
3040
|
-
|
|
3041
|
-
// eslint-disable-next-line unicorn/prevent-abbreviations
|
|
3042
|
-
export type Lib =
|
|
3043
|
-
| 'ES5'
|
|
3044
|
-
| 'ES6'
|
|
3045
|
-
| 'ES7'
|
|
3046
|
-
| 'ES2015'
|
|
3047
|
-
| 'ES2015.Collection'
|
|
3048
|
-
| 'ES2015.Core'
|
|
3049
|
-
| 'ES2015.Generator'
|
|
3050
|
-
| 'ES2015.Iterable'
|
|
3051
|
-
| 'ES2015.Promise'
|
|
3052
|
-
| 'ES2015.Proxy'
|
|
3053
|
-
| 'ES2015.Reflect'
|
|
3054
|
-
| 'ES2015.Symbol.WellKnown'
|
|
3055
|
-
| 'ES2015.Symbol'
|
|
3056
|
-
| 'ES2016'
|
|
3057
|
-
| 'ES2016.Array.Include'
|
|
3058
|
-
| 'ES2017'
|
|
3059
|
-
| 'ES2017.ArrayBuffer'
|
|
3060
|
-
| 'ES2017.Date'
|
|
3061
|
-
| 'ES2017.Intl'
|
|
3062
|
-
| 'ES2017.Object'
|
|
3063
|
-
| 'ES2017.SharedMemory'
|
|
3064
|
-
| 'ES2017.String'
|
|
3065
|
-
| 'ES2017.TypedArrays'
|
|
3066
|
-
| 'ES2018'
|
|
3067
|
-
| 'ES2018.AsyncGenerator'
|
|
3068
|
-
| 'ES2018.AsyncIterable'
|
|
3069
|
-
| 'ES2018.Intl'
|
|
3070
|
-
| 'ES2018.Promise'
|
|
3071
|
-
| 'ES2018.Regexp'
|
|
3072
|
-
| 'ES2019'
|
|
3073
|
-
| 'ES2019.Array'
|
|
3074
|
-
| 'ES2019.Object'
|
|
3075
|
-
| 'ES2019.String'
|
|
3076
|
-
| 'ES2019.Symbol'
|
|
3077
|
-
| 'ES2020'
|
|
3078
|
-
| 'ES2020.BigInt'
|
|
3079
|
-
| 'ES2020.Promise'
|
|
3080
|
-
| 'ES2020.String'
|
|
3081
|
-
| 'ES2020.Symbol.WellKnown'
|
|
3082
|
-
| 'ES2020.SharedMemory'
|
|
3083
|
-
| 'ES2020.Intl'
|
|
3084
|
-
| 'ES2021'
|
|
3085
|
-
| 'ES2021.Intl'
|
|
3086
|
-
| 'ES2021.Promise'
|
|
3087
|
-
| 'ES2021.String'
|
|
3088
|
-
| 'ES2021.WeakRef'
|
|
3089
|
-
| 'ES2022'
|
|
3090
|
-
| 'ES2022.Array'
|
|
3091
|
-
| 'ES2022.Error'
|
|
3092
|
-
| 'ES2022.Intl'
|
|
3093
|
-
| 'ES2022.Object'
|
|
3094
|
-
| 'ES2022.RegExp'
|
|
3095
|
-
| 'ES2022.String'
|
|
3096
|
-
| 'ES2023'
|
|
3097
|
-
| 'ES2023.Array'
|
|
3098
|
-
| 'ES2023.Collection'
|
|
3099
|
-
| 'ES2023.Intl'
|
|
3100
|
-
| 'ES2024'
|
|
3101
|
-
| 'ES2024.ArrayBuffer'
|
|
3102
|
-
| 'ES2024.Collection'
|
|
3103
|
-
| 'ES2024.Object'
|
|
3104
|
-
| 'ES2024.Promise'
|
|
3105
|
-
| 'ES2024.Regexp'
|
|
3106
|
-
| 'ES2024.SharedMemory'
|
|
3107
|
-
| 'ES2024.String'
|
|
3108
|
-
| 'ESNext'
|
|
3109
|
-
| 'ESNext.Array'
|
|
3110
|
-
| 'ESNext.AsyncIterable'
|
|
3111
|
-
| 'ESNext.BigInt'
|
|
3112
|
-
| 'ESNext.Collection'
|
|
3113
|
-
| 'ESNext.Decorators'
|
|
3114
|
-
| 'ESNext.Disposable'
|
|
3115
|
-
| 'ESNext.Intl'
|
|
3116
|
-
| 'ESNext.Iterator'
|
|
3117
|
-
| 'ESNext.Promise'
|
|
3118
|
-
| 'ESNext.String'
|
|
3119
|
-
| 'ESNext.Symbol'
|
|
3120
|
-
| 'ESNext.WeakRef'
|
|
3121
|
-
| 'DOM'
|
|
3122
|
-
| 'DOM.Iterable'
|
|
3123
|
-
| 'ScriptHost'
|
|
3124
|
-
| 'WebWorker'
|
|
3125
|
-
| 'WebWorker.AsyncIterable'
|
|
3126
|
-
| 'WebWorker.ImportScripts'
|
|
3127
|
-
| 'WebWorker.Iterable'
|
|
3128
|
-
// Lowercase alternatives
|
|
3129
|
-
| 'es5'
|
|
3130
|
-
| 'es6'
|
|
3131
|
-
| 'es7'
|
|
3132
|
-
| 'es2015'
|
|
3133
|
-
| 'es2015.collection'
|
|
3134
|
-
| 'es2015.core'
|
|
3135
|
-
| 'es2015.generator'
|
|
3136
|
-
| 'es2015.iterable'
|
|
3137
|
-
| 'es2015.promise'
|
|
3138
|
-
| 'es2015.proxy'
|
|
3139
|
-
| 'es2015.reflect'
|
|
3140
|
-
| 'es2015.symbol.wellknown'
|
|
3141
|
-
| 'es2015.symbol'
|
|
3142
|
-
| 'es2016'
|
|
3143
|
-
| 'es2016.array.include'
|
|
3144
|
-
| 'es2017'
|
|
3145
|
-
| 'es2017.arraybuffer'
|
|
3146
|
-
| 'es2017.date'
|
|
3147
|
-
| 'es2017.intl'
|
|
3148
|
-
| 'es2017.object'
|
|
3149
|
-
| 'es2017.sharedmemory'
|
|
3150
|
-
| 'es2017.string'
|
|
3151
|
-
| 'es2017.typedarrays'
|
|
3152
|
-
| 'es2018'
|
|
3153
|
-
| 'es2018.asyncgenerator'
|
|
3154
|
-
| 'es2018.asynciterable'
|
|
3155
|
-
| 'es2018.intl'
|
|
3156
|
-
| 'es2018.promise'
|
|
3157
|
-
| 'es2018.regexp'
|
|
3158
|
-
| 'es2019'
|
|
3159
|
-
| 'es2019.array'
|
|
3160
|
-
| 'es2019.object'
|
|
3161
|
-
| 'es2019.string'
|
|
3162
|
-
| 'es2019.symbol'
|
|
3163
|
-
| 'es2020'
|
|
3164
|
-
| 'es2020.bigint'
|
|
3165
|
-
| 'es2020.promise'
|
|
3166
|
-
| 'es2020.string'
|
|
3167
|
-
| 'es2020.symbol.wellknown'
|
|
3168
|
-
| 'es2020.sharedmemory'
|
|
3169
|
-
| 'es2020.intl'
|
|
3170
|
-
| 'es2021'
|
|
3171
|
-
| 'es2021.intl'
|
|
3172
|
-
| 'es2021.promise'
|
|
3173
|
-
| 'es2021.string'
|
|
3174
|
-
| 'es2021.weakref'
|
|
3175
|
-
| 'es2022'
|
|
3176
|
-
| 'es2022.array'
|
|
3177
|
-
| 'es2022.error'
|
|
3178
|
-
| 'es2022.intl'
|
|
3179
|
-
| 'es2022.object'
|
|
3180
|
-
| 'es2022.regexp'
|
|
3181
|
-
| 'es2022.string'
|
|
3182
|
-
| 'es2023'
|
|
3183
|
-
| 'es2023.array'
|
|
3184
|
-
| 'es2023.collection'
|
|
3185
|
-
| 'es2023.intl'
|
|
3186
|
-
| 'es2024'
|
|
3187
|
-
| 'es2024.arraybuffer'
|
|
3188
|
-
| 'es2024.collection'
|
|
3189
|
-
| 'es2024.object'
|
|
3190
|
-
| 'es2024.promise'
|
|
3191
|
-
| 'es2024.regexp'
|
|
3192
|
-
| 'es2024.sharedmemory'
|
|
3193
|
-
| 'es2024.string'
|
|
3194
|
-
| 'esnext'
|
|
3195
|
-
| 'esnext.array'
|
|
3196
|
-
| 'esnext.asynciterable'
|
|
3197
|
-
| 'esnext.bigint'
|
|
3198
|
-
| 'esnext.collection'
|
|
3199
|
-
| 'esnext.decorators'
|
|
3200
|
-
| 'esnext.disposable'
|
|
3201
|
-
| 'esnext.intl'
|
|
3202
|
-
| 'esnext.iterator'
|
|
3203
|
-
| 'esnext.promise'
|
|
3204
|
-
| 'esnext.string'
|
|
3205
|
-
| 'esnext.symbol'
|
|
3206
|
-
| 'esnext.weakref'
|
|
3207
|
-
| 'dom'
|
|
3208
|
-
| 'dom.iterable'
|
|
3209
|
-
| 'scripthost'
|
|
3210
|
-
| 'webworker'
|
|
3211
|
-
| 'webworker.asynciterable'
|
|
3212
|
-
| 'webworker.importscripts'
|
|
3213
|
-
| 'webworker.iterable';
|
|
3214
|
-
|
|
3215
|
-
export type Plugin = {
|
|
3216
|
-
/**
|
|
3217
|
-
Plugin name.
|
|
3218
|
-
*/
|
|
3219
|
-
name: string;
|
|
3220
|
-
};
|
|
3221
|
-
|
|
3222
|
-
export type ImportsNotUsedAsValues =
|
|
3223
|
-
| 'remove'
|
|
3224
|
-
| 'preserve'
|
|
3225
|
-
| 'error';
|
|
3226
|
-
|
|
3227
|
-
export type FallbackPolling =
|
|
3228
|
-
| 'fixedPollingInterval'
|
|
3229
|
-
| 'priorityPollingInterval'
|
|
3230
|
-
| 'dynamicPriorityPolling'
|
|
3231
|
-
| 'fixedInterval'
|
|
3232
|
-
| 'priorityInterval'
|
|
3233
|
-
| 'dynamicPriority'
|
|
3234
|
-
| 'fixedChunkSize';
|
|
3235
|
-
|
|
3236
|
-
export type WatchDirectory =
|
|
3237
|
-
| 'useFsEvents'
|
|
3238
|
-
| 'fixedPollingInterval'
|
|
3239
|
-
| 'dynamicPriorityPolling'
|
|
3240
|
-
| 'fixedChunkSizePolling';
|
|
3241
|
-
|
|
3242
|
-
export type WatchFile =
|
|
3243
|
-
| 'fixedPollingInterval'
|
|
3244
|
-
| 'priorityPollingInterval'
|
|
3245
|
-
| 'dynamicPriorityPolling'
|
|
3246
|
-
| 'useFsEvents'
|
|
3247
|
-
| 'useFsEventsOnParentDirectory'
|
|
3248
|
-
| 'fixedChunkSizePolling';
|
|
3249
|
-
|
|
3250
|
-
export type ModuleResolution =
|
|
3251
|
-
| 'classic'
|
|
3252
|
-
| 'node'
|
|
3253
|
-
| 'node10'
|
|
3254
|
-
| 'node16'
|
|
3255
|
-
| 'nodenext'
|
|
3256
|
-
| 'bundler'
|
|
3257
|
-
// Pascal-cased alternatives
|
|
3258
|
-
| 'Classic'
|
|
3259
|
-
| 'Node'
|
|
3260
|
-
| 'Node10'
|
|
3261
|
-
| 'Node16'
|
|
3262
|
-
| 'NodeNext'
|
|
3263
|
-
| 'Bundler';
|
|
3264
|
-
|
|
3265
|
-
export type ModuleDetection =
|
|
3266
|
-
| 'auto'
|
|
3267
|
-
| 'legacy'
|
|
3268
|
-
| 'force';
|
|
3269
|
-
|
|
3270
|
-
export type IgnoreDeprecations = '5.0';
|
|
3271
|
-
}
|
|
3272
|
-
|
|
3273
|
-
export type CompilerOptions = {
|
|
3274
|
-
/**
|
|
3275
|
-
The character set of the input files.
|
|
3276
|
-
|
|
3277
|
-
@default 'utf8'
|
|
3278
|
-
@deprecated This option will be removed in TypeScript 5.5.
|
|
3279
|
-
*/
|
|
3280
|
-
charset?: string;
|
|
3281
|
-
|
|
3282
|
-
/**
|
|
3283
|
-
Enables building for project references.
|
|
3284
|
-
|
|
3285
|
-
@default true
|
|
3286
|
-
*/
|
|
3287
|
-
composite?: boolean;
|
|
3288
|
-
|
|
3289
|
-
/**
|
|
3290
|
-
Generates corresponding d.ts files.
|
|
3291
|
-
|
|
3292
|
-
@default false
|
|
3293
|
-
*/
|
|
3294
|
-
declaration?: boolean;
|
|
3295
|
-
|
|
3296
|
-
/**
|
|
3297
|
-
Specify output directory for generated declaration files.
|
|
3298
|
-
*/
|
|
3299
|
-
declarationDir?: string;
|
|
3300
|
-
|
|
3301
|
-
/**
|
|
3302
|
-
Show diagnostic information.
|
|
3303
|
-
|
|
3304
|
-
@default false
|
|
3305
|
-
*/
|
|
3306
|
-
diagnostics?: boolean;
|
|
3307
|
-
|
|
3308
|
-
/**
|
|
3309
|
-
Reduce the number of projects loaded automatically by TypeScript.
|
|
3310
|
-
|
|
3311
|
-
@default false
|
|
3312
|
-
*/
|
|
3313
|
-
disableReferencedProjectLoad?: boolean;
|
|
3314
|
-
|
|
3315
|
-
/**
|
|
3316
|
-
Enforces using indexed accessors for keys declared using an indexed type.
|
|
3317
|
-
|
|
3318
|
-
@default false
|
|
3319
|
-
*/
|
|
3320
|
-
noPropertyAccessFromIndexSignature?: boolean;
|
|
3321
|
-
|
|
3322
|
-
/**
|
|
3323
|
-
Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.
|
|
3324
|
-
|
|
3325
|
-
@default false
|
|
3326
|
-
*/
|
|
3327
|
-
emitBOM?: boolean;
|
|
3328
|
-
|
|
3329
|
-
/**
|
|
3330
|
-
Only emit `.d.ts` declaration files.
|
|
3331
|
-
|
|
3332
|
-
@default false
|
|
3333
|
-
*/
|
|
3334
|
-
emitDeclarationOnly?: boolean;
|
|
3335
|
-
|
|
3336
|
-
/**
|
|
3337
|
-
Differentiate between undefined and not present when type checking.
|
|
3338
|
-
|
|
3339
|
-
@default false
|
|
3340
|
-
*/
|
|
3341
|
-
exactOptionalPropertyTypes?: boolean;
|
|
3342
|
-
|
|
3343
|
-
/**
|
|
3344
|
-
Enable incremental compilation.
|
|
3345
|
-
|
|
3346
|
-
@default `composite`
|
|
3347
|
-
*/
|
|
3348
|
-
incremental?: boolean;
|
|
3349
|
-
|
|
3350
|
-
/**
|
|
3351
|
-
Specify file to store incremental compilation information.
|
|
3352
|
-
|
|
3353
|
-
@default '.tsbuildinfo'
|
|
3354
|
-
*/
|
|
3355
|
-
tsBuildInfoFile?: string;
|
|
3356
|
-
|
|
3357
|
-
/**
|
|
3358
|
-
Emit a single file with source maps instead of having a separate file.
|
|
3359
|
-
|
|
3360
|
-
@default false
|
|
3361
|
-
*/
|
|
3362
|
-
inlineSourceMap?: boolean;
|
|
3363
|
-
|
|
3364
|
-
/**
|
|
3365
|
-
Emit the source alongside the sourcemaps within a single file.
|
|
3366
|
-
|
|
3367
|
-
Requires `--inlineSourceMap` to be set.
|
|
3368
|
-
|
|
3369
|
-
@default false
|
|
3370
|
-
*/
|
|
3371
|
-
inlineSources?: boolean;
|
|
3372
|
-
|
|
3373
|
-
/**
|
|
3374
|
-
Specify what JSX code is generated.
|
|
3375
|
-
|
|
3376
|
-
@default 'preserve'
|
|
3377
|
-
*/
|
|
3378
|
-
jsx?: CompilerOptions.JSX;
|
|
3379
|
-
|
|
3380
|
-
/**
|
|
3381
|
-
Specifies the object invoked for `createElement` and `__spread` when targeting `'react'` JSX emit.
|
|
3382
|
-
|
|
3383
|
-
@default 'React'
|
|
3384
|
-
*/
|
|
3385
|
-
reactNamespace?: string;
|
|
3386
|
-
|
|
3387
|
-
/**
|
|
3388
|
-
Specify the JSX factory function to use when targeting React JSX emit, e.g. `React.createElement` or `h`.
|
|
3389
|
-
|
|
3390
|
-
@default 'React.createElement'
|
|
3391
|
-
*/
|
|
3392
|
-
jsxFactory?: string;
|
|
3393
|
-
|
|
3394
|
-
/**
|
|
3395
|
-
Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'.
|
|
3396
|
-
|
|
3397
|
-
@default 'React.Fragment'
|
|
3398
|
-
*/
|
|
3399
|
-
jsxFragmentFactory?: string;
|
|
3400
|
-
|
|
3401
|
-
/**
|
|
3402
|
-
Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.
|
|
3403
|
-
|
|
3404
|
-
@default 'react'
|
|
3405
|
-
*/
|
|
3406
|
-
jsxImportSource?: string;
|
|
3407
|
-
|
|
3408
|
-
/**
|
|
3409
|
-
Print names of files part of the compilation.
|
|
3410
|
-
|
|
3411
|
-
@default false
|
|
3412
|
-
*/
|
|
3413
|
-
listFiles?: boolean;
|
|
3414
|
-
|
|
3415
|
-
/**
|
|
3416
|
-
Specifies the location where debugger should locate map files instead of generated locations.
|
|
3417
|
-
*/
|
|
3418
|
-
mapRoot?: string;
|
|
3419
|
-
|
|
3420
|
-
/**
|
|
3421
|
-
Specify module code generation: 'None', 'CommonJS', 'AMD', 'System', 'UMD', 'ES6', 'ES2015' or 'ESNext'. Only 'AMD' and 'System' can be used in conjunction with `--outFile`. 'ES6' and 'ES2015' values may be used when targeting 'ES5' or lower.
|
|
3422
|
-
|
|
3423
|
-
@default ['ES3', 'ES5'].includes(target) ? 'CommonJS' : 'ES6'
|
|
3424
|
-
*/
|
|
3425
|
-
module?: CompilerOptions.Module;
|
|
3426
|
-
|
|
3427
|
-
/**
|
|
3428
|
-
Specifies module resolution strategy: 'node' (Node) or 'classic' (TypeScript pre 1.6).
|
|
3429
|
-
|
|
3430
|
-
@default ['AMD', 'System', 'ES6'].includes(module) ? 'classic' : 'node'
|
|
3431
|
-
*/
|
|
3432
|
-
moduleResolution?: CompilerOptions.ModuleResolution;
|
|
3433
|
-
|
|
3434
|
-
/**
|
|
3435
|
-
Specifies the end of line sequence to be used when emitting files: 'crlf' (Windows) or 'lf' (Unix).
|
|
3436
|
-
|
|
3437
|
-
@default 'LF'
|
|
3438
|
-
*/
|
|
3439
|
-
newLine?: CompilerOptions.NewLine;
|
|
3440
|
-
|
|
3441
|
-
/**
|
|
3442
|
-
Disable full type checking (only critical parse and emit errors will be reported).
|
|
3443
|
-
|
|
3444
|
-
@default false
|
|
3445
|
-
*/
|
|
3446
|
-
noCheck?: boolean;
|
|
3447
|
-
|
|
3448
|
-
/**
|
|
3449
|
-
Do not emit output.
|
|
3450
|
-
|
|
3451
|
-
@default false
|
|
3452
|
-
*/
|
|
3453
|
-
noEmit?: boolean;
|
|
3454
|
-
|
|
3455
|
-
/**
|
|
3456
|
-
Do not generate custom helper functions like `__extends` in compiled output.
|
|
3457
|
-
|
|
3458
|
-
@default false
|
|
3459
|
-
*/
|
|
3460
|
-
noEmitHelpers?: boolean;
|
|
3461
|
-
|
|
3462
|
-
/**
|
|
3463
|
-
Do not emit outputs if any type checking errors were reported.
|
|
3464
|
-
|
|
3465
|
-
@default false
|
|
3466
|
-
*/
|
|
3467
|
-
noEmitOnError?: boolean;
|
|
3468
|
-
|
|
3469
|
-
/**
|
|
3470
|
-
Warn on expressions and declarations with an implied 'any' type.
|
|
3471
|
-
|
|
3472
|
-
@default false
|
|
3473
|
-
*/
|
|
3474
|
-
noImplicitAny?: boolean;
|
|
3475
|
-
|
|
3476
|
-
/**
|
|
3477
|
-
Raise error on 'this' expressions with an implied any type.
|
|
3478
|
-
|
|
3479
|
-
@default false
|
|
3480
|
-
*/
|
|
3481
|
-
noImplicitThis?: boolean;
|
|
3482
|
-
|
|
3483
|
-
/**
|
|
3484
|
-
Report errors on unused locals.
|
|
3485
|
-
|
|
3486
|
-
@default false
|
|
3487
|
-
*/
|
|
3488
|
-
noUnusedLocals?: boolean;
|
|
3489
|
-
|
|
3490
|
-
/**
|
|
3491
|
-
Report errors on unused parameters.
|
|
3492
|
-
|
|
3493
|
-
@default false
|
|
3494
|
-
*/
|
|
3495
|
-
noUnusedParameters?: boolean;
|
|
3496
|
-
|
|
3497
|
-
/**
|
|
3498
|
-
Do not include the default library file (lib.d.ts).
|
|
3499
|
-
|
|
3500
|
-
@default false
|
|
3501
|
-
*/
|
|
3502
|
-
noLib?: boolean;
|
|
3503
|
-
|
|
3504
|
-
/**
|
|
3505
|
-
Do not add triple-slash references or module import targets to the list of compiled files.
|
|
3506
|
-
|
|
3507
|
-
@default false
|
|
3508
|
-
*/
|
|
3509
|
-
noResolve?: boolean;
|
|
3510
|
-
|
|
3511
|
-
/**
|
|
3512
|
-
Disable strict checking of generic signatures in function types.
|
|
3513
|
-
|
|
3514
|
-
@default false
|
|
3515
|
-
@deprecated This option will be removed in TypeScript 5.5.
|
|
3516
|
-
*/
|
|
3517
|
-
noStrictGenericChecks?: boolean;
|
|
3518
|
-
|
|
3519
|
-
/**
|
|
3520
|
-
@deprecated use `skipLibCheck` instead.
|
|
3521
|
-
*/
|
|
3522
|
-
skipDefaultLibCheck?: boolean;
|
|
3523
|
-
|
|
3524
|
-
/**
|
|
3525
|
-
Skip type checking of declaration files.
|
|
3526
|
-
|
|
3527
|
-
@default false
|
|
3528
|
-
*/
|
|
3529
|
-
skipLibCheck?: boolean;
|
|
3530
|
-
|
|
3531
|
-
/**
|
|
3532
|
-
Concatenate and emit output to single file.
|
|
3533
|
-
*/
|
|
3534
|
-
outFile?: string;
|
|
3535
|
-
|
|
3536
|
-
/**
|
|
3537
|
-
Redirect output structure to the directory.
|
|
3538
|
-
*/
|
|
3539
|
-
outDir?: string;
|
|
3540
|
-
|
|
3541
|
-
/**
|
|
3542
|
-
Do not erase const enum declarations in generated code.
|
|
3543
|
-
|
|
3544
|
-
@default false
|
|
3545
|
-
*/
|
|
3546
|
-
preserveConstEnums?: boolean;
|
|
3547
|
-
|
|
3548
|
-
/**
|
|
3549
|
-
Do not resolve symlinks to their real path; treat a symlinked file like a real one.
|
|
3550
|
-
|
|
3551
|
-
@default false
|
|
3552
|
-
*/
|
|
3553
|
-
preserveSymlinks?: boolean;
|
|
3554
|
-
|
|
3555
|
-
/**
|
|
3556
|
-
Keep outdated console output in watch mode instead of clearing the screen.
|
|
3557
|
-
|
|
3558
|
-
@default false
|
|
3559
|
-
*/
|
|
3560
|
-
preserveWatchOutput?: boolean;
|
|
3561
|
-
|
|
3562
|
-
/**
|
|
3563
|
-
Stylize errors and messages using color and context (experimental).
|
|
3564
|
-
|
|
3565
|
-
@default true // Unless piping to another program or redirecting output to a file.
|
|
3566
|
-
*/
|
|
3567
|
-
pretty?: boolean;
|
|
3568
|
-
|
|
3569
|
-
/**
|
|
3570
|
-
Do not emit comments to output.
|
|
3571
|
-
|
|
3572
|
-
@default false
|
|
3573
|
-
*/
|
|
3574
|
-
removeComments?: boolean;
|
|
3575
|
-
|
|
3576
|
-
/**
|
|
3577
|
-
Specifies the root directory of input files.
|
|
3578
|
-
|
|
3579
|
-
Use to control the output directory structure with `--outDir`.
|
|
3580
|
-
*/
|
|
3581
|
-
rootDir?: string;
|
|
3582
|
-
|
|
3583
|
-
/**
|
|
3584
|
-
Unconditionally emit imports for unresolved files.
|
|
3585
|
-
|
|
3586
|
-
@default false
|
|
3587
|
-
*/
|
|
3588
|
-
isolatedModules?: boolean;
|
|
3589
|
-
|
|
3590
|
-
/**
|
|
3591
|
-
Require sufficient annotation on exports so other tools can trivially generate declaration files.
|
|
3592
|
-
|
|
3593
|
-
@default false
|
|
3594
|
-
*/
|
|
3595
|
-
isolatedDeclarations?: boolean;
|
|
3596
|
-
|
|
3597
|
-
/**
|
|
3598
|
-
Generates corresponding '.map' file.
|
|
3599
|
-
|
|
3600
|
-
@default false
|
|
3601
|
-
*/
|
|
3602
|
-
sourceMap?: boolean;
|
|
3603
|
-
|
|
3604
|
-
/**
|
|
3605
|
-
Specifies the location where debugger should locate TypeScript files instead of source locations.
|
|
3606
|
-
*/
|
|
3607
|
-
sourceRoot?: string;
|
|
3608
|
-
|
|
3609
|
-
/**
|
|
3610
|
-
Suppress excess property checks for object literals.
|
|
3611
|
-
|
|
3612
|
-
@default false
|
|
3613
|
-
@deprecated This option will be removed in TypeScript 5.5.
|
|
3614
|
-
*/
|
|
3615
|
-
suppressExcessPropertyErrors?: boolean;
|
|
3616
|
-
|
|
3617
|
-
/**
|
|
3618
|
-
Suppress noImplicitAny errors for indexing objects lacking index signatures.
|
|
3619
|
-
|
|
3620
|
-
@default false
|
|
3621
|
-
@deprecated This option will be removed in TypeScript 5.5.
|
|
3622
|
-
*/
|
|
3623
|
-
suppressImplicitAnyIndexErrors?: boolean;
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
/**
|
|
3628
|
-
Specify ECMAScript target version.
|
|
3629
|
-
|
|
3630
|
-
@default 'es3'
|
|
3631
|
-
*/
|
|
3632
|
-
target?: CompilerOptions.Target;
|
|
3633
|
-
|
|
3634
|
-
/**
|
|
3635
|
-
Default catch clause variables as `unknown` instead of `any`.
|
|
3636
|
-
|
|
3637
|
-
@default false
|
|
3638
|
-
*/
|
|
3639
|
-
useUnknownInCatchVariables?: boolean;
|
|
3640
|
-
|
|
3641
|
-
/**
|
|
3642
|
-
Watch input files.
|
|
3643
|
-
|
|
3644
|
-
@default false
|
|
3645
|
-
@deprecated Use watchOptions instead.
|
|
3646
|
-
*/
|
|
3647
|
-
watch?: boolean;
|
|
3648
|
-
|
|
3649
|
-
/**
|
|
3650
|
-
Specify the polling strategy to use when the system runs out of or doesn't support native file watchers.
|
|
3651
|
-
|
|
3652
|
-
@deprecated Use watchOptions.fallbackPolling instead.
|
|
3653
|
-
*/
|
|
3654
|
-
fallbackPolling?: CompilerOptions.FallbackPolling;
|
|
3655
|
-
|
|
3656
|
-
/**
|
|
3657
|
-
Specify the strategy for watching directories under systems that lack recursive file-watching functionality.
|
|
3658
|
-
|
|
3659
|
-
@default 'useFsEvents'
|
|
3660
|
-
@deprecated Use watchOptions.watchDirectory instead.
|
|
3661
|
-
*/
|
|
3662
|
-
watchDirectory?: CompilerOptions.WatchDirectory;
|
|
3663
|
-
|
|
3664
|
-
/**
|
|
3665
|
-
Specify the strategy for watching individual files.
|
|
3666
|
-
|
|
3667
|
-
@default 'useFsEvents'
|
|
3668
|
-
@deprecated Use watchOptions.watchFile instead.
|
|
3669
|
-
*/
|
|
3670
|
-
watchFile?: CompilerOptions.WatchFile;
|
|
3671
|
-
|
|
3672
|
-
/**
|
|
3673
|
-
Enables experimental support for ES7 decorators.
|
|
3674
|
-
|
|
3675
|
-
@default false
|
|
3676
|
-
*/
|
|
3677
|
-
experimentalDecorators?: boolean;
|
|
3678
|
-
|
|
3679
|
-
/**
|
|
3680
|
-
Emit design-type metadata for decorated declarations in source.
|
|
3681
|
-
|
|
3682
|
-
@default false
|
|
3683
|
-
*/
|
|
3684
|
-
emitDecoratorMetadata?: boolean;
|
|
3685
|
-
|
|
3686
|
-
/**
|
|
3687
|
-
Do not report errors on unused labels.
|
|
3688
|
-
|
|
3689
|
-
@default false
|
|
3690
|
-
*/
|
|
3691
|
-
allowUnusedLabels?: boolean;
|
|
3692
|
-
|
|
3693
|
-
/**
|
|
3694
|
-
Report error when not all code paths in function return a value.
|
|
3695
|
-
|
|
3696
|
-
@default false
|
|
3697
|
-
*/
|
|
3698
|
-
noImplicitReturns?: boolean;
|
|
3699
|
-
|
|
3700
|
-
/**
|
|
3701
|
-
Add `undefined` to a type when accessed using an index.
|
|
3702
|
-
|
|
3703
|
-
@default false
|
|
3704
|
-
*/
|
|
3705
|
-
noUncheckedIndexedAccess?: boolean;
|
|
3706
|
-
|
|
3707
|
-
/**
|
|
3708
|
-
Report error if failed to find a source file for a side effect import.
|
|
3709
|
-
|
|
3710
|
-
@default false
|
|
3711
|
-
*/
|
|
3712
|
-
noUncheckedSideEffectImports?: boolean;
|
|
3713
|
-
|
|
3714
|
-
/**
|
|
3715
|
-
Report errors for fallthrough cases in switch statement.
|
|
3716
|
-
|
|
3717
|
-
@default false
|
|
3718
|
-
*/
|
|
3719
|
-
noFallthroughCasesInSwitch?: boolean;
|
|
3720
|
-
|
|
3721
|
-
/**
|
|
3722
|
-
Ensure overriding members in derived classes are marked with an override modifier.
|
|
3723
|
-
|
|
3724
|
-
@default false
|
|
3725
|
-
*/
|
|
3726
|
-
noImplicitOverride?: boolean;
|
|
3727
|
-
|
|
3728
|
-
/**
|
|
3729
|
-
Do not report errors on unreachable code.
|
|
3730
|
-
|
|
3731
|
-
@default false
|
|
3732
|
-
*/
|
|
3733
|
-
allowUnreachableCode?: boolean;
|
|
3734
|
-
|
|
3735
|
-
/**
|
|
3736
|
-
Disallow inconsistently-cased references to the same file.
|
|
3737
|
-
|
|
3738
|
-
@default true
|
|
3739
|
-
*/
|
|
3740
|
-
forceConsistentCasingInFileNames?: boolean;
|
|
3741
|
-
|
|
3742
|
-
/**
|
|
3743
|
-
Emit a v8 CPU profile of the compiler run for debugging.
|
|
3744
|
-
|
|
3745
|
-
@default 'profile.cpuprofile'
|
|
3746
|
-
*/
|
|
3747
|
-
generateCpuProfile?: string;
|
|
3748
|
-
|
|
3749
|
-
/**
|
|
3750
|
-
Generates an event trace and a list of types.
|
|
3751
|
-
*/
|
|
3752
|
-
generateTrace?: boolean;
|
|
3753
|
-
|
|
3754
|
-
/**
|
|
3755
|
-
Base directory to resolve non-relative module names.
|
|
3756
|
-
*/
|
|
3757
|
-
baseUrl?: string;
|
|
3758
|
-
|
|
3759
|
-
/**
|
|
3760
|
-
Specify path mapping to be computed relative to baseUrl option.
|
|
3761
|
-
*/
|
|
3762
|
-
paths?: Record<string, string[]>;
|
|
3763
|
-
|
|
3764
|
-
/**
|
|
3765
|
-
List of TypeScript language server plugins to load.
|
|
3766
|
-
*/
|
|
3767
|
-
plugins?: CompilerOptions.Plugin[];
|
|
3768
|
-
|
|
3769
|
-
/**
|
|
3770
|
-
Specify list of root directories to be used when resolving modules.
|
|
3771
|
-
*/
|
|
3772
|
-
rootDirs?: string[];
|
|
3773
|
-
|
|
3774
|
-
/**
|
|
3775
|
-
Specify list of directories for type definition files to be included.
|
|
3776
|
-
*/
|
|
3777
|
-
typeRoots?: string[];
|
|
3778
|
-
|
|
3779
|
-
/**
|
|
3780
|
-
Type declaration files to be included in compilation.
|
|
3781
|
-
*/
|
|
3782
|
-
types?: string[];
|
|
3783
|
-
|
|
3784
|
-
/**
|
|
3785
|
-
Enable tracing of the name resolution process.
|
|
3786
|
-
|
|
3787
|
-
@default false
|
|
3788
|
-
*/
|
|
3789
|
-
traceResolution?: boolean;
|
|
3790
|
-
|
|
3791
|
-
/**
|
|
3792
|
-
Allow javascript files to be compiled.
|
|
3793
|
-
|
|
3794
|
-
@default false
|
|
3795
|
-
*/
|
|
3796
|
-
allowJs?: boolean;
|
|
3797
|
-
|
|
3798
|
-
/**
|
|
3799
|
-
Do not truncate error messages.
|
|
3800
|
-
|
|
3801
|
-
@default false
|
|
3802
|
-
*/
|
|
3803
|
-
noErrorTruncation?: boolean;
|
|
3804
|
-
|
|
3805
|
-
/**
|
|
3806
|
-
Allow default imports from modules with no default export. This does not affect code emit, just typechecking.
|
|
3807
|
-
|
|
3808
|
-
@default module === 'system' || esModuleInterop
|
|
3809
|
-
*/
|
|
3810
|
-
allowSyntheticDefaultImports?: boolean;
|
|
3811
|
-
|
|
3812
|
-
/**
|
|
3813
|
-
Do not emit `'use strict'` directives in module output.
|
|
3814
|
-
|
|
3815
|
-
@default false
|
|
3816
|
-
@deprecated This option will be removed in TypeScript 5.5.
|
|
3817
|
-
*/
|
|
3818
|
-
noImplicitUseStrict?: boolean;
|
|
3819
|
-
|
|
3820
|
-
/**
|
|
3821
|
-
Enable to list all emitted files.
|
|
3822
|
-
|
|
3823
|
-
@default false
|
|
3824
|
-
*/
|
|
3825
|
-
listEmittedFiles?: boolean;
|
|
3826
|
-
|
|
3827
|
-
/**
|
|
3828
|
-
Disable size limit for JavaScript project.
|
|
3829
|
-
|
|
3830
|
-
@default false
|
|
3831
|
-
*/
|
|
3832
|
-
disableSizeLimit?: boolean;
|
|
3833
|
-
|
|
3834
|
-
/**
|
|
3835
|
-
List of library files to be included in the compilation.
|
|
3836
|
-
*/
|
|
3837
|
-
lib?: CompilerOptions.Lib[];
|
|
3838
|
-
|
|
3839
|
-
/**
|
|
3840
|
-
Enable strict null checks.
|
|
3841
|
-
|
|
3842
|
-
@default false
|
|
3843
|
-
*/
|
|
3844
|
-
strictNullChecks?: boolean;
|
|
3845
|
-
|
|
3846
|
-
/**
|
|
3847
|
-
The maximum dependency depth to search under `node_modules` and load JavaScript files. Only applicable with `--allowJs`.
|
|
3848
|
-
|
|
3849
|
-
@default 0
|
|
3850
|
-
*/
|
|
3851
|
-
maxNodeModuleJsDepth?: number;
|
|
3852
|
-
|
|
3853
|
-
/**
|
|
3854
|
-
Import emit helpers (e.g. `__extends`, `__rest`, etc..) from tslib.
|
|
3855
|
-
|
|
3856
|
-
@default false
|
|
3857
|
-
*/
|
|
3858
|
-
importHelpers?: boolean;
|
|
3859
|
-
|
|
3860
|
-
/**
|
|
3861
|
-
Specify emit/checking behavior for imports that are only used for types.
|
|
3862
|
-
|
|
3863
|
-
@default 'remove'
|
|
3864
|
-
@deprecated Use `verbatimModuleSyntax` instead.
|
|
3865
|
-
*/
|
|
3866
|
-
importsNotUsedAsValues?: CompilerOptions.ImportsNotUsedAsValues;
|
|
3867
|
-
|
|
3868
|
-
/**
|
|
3869
|
-
Parse in strict mode and emit `'use strict'` for each source file.
|
|
3870
|
-
|
|
3871
|
-
@default false
|
|
3872
|
-
*/
|
|
3873
|
-
alwaysStrict?: boolean;
|
|
3874
|
-
|
|
3875
|
-
/**
|
|
3876
|
-
Enable all strict type checking options.
|
|
3877
|
-
|
|
3878
|
-
@default false
|
|
3879
|
-
*/
|
|
3880
|
-
strict?: boolean;
|
|
3881
|
-
|
|
3882
|
-
/**
|
|
3883
|
-
Enable stricter checking of of the `bind`, `call`, and `apply` methods on functions.
|
|
3884
|
-
|
|
3885
|
-
@default false
|
|
3886
|
-
*/
|
|
3887
|
-
strictBindCallApply?: boolean;
|
|
3888
|
-
|
|
3889
|
-
/**
|
|
3890
|
-
Provide full support for iterables in `for-of`, spread, and destructuring when targeting `ES5` or `ES3`.
|
|
3891
|
-
|
|
3892
|
-
@default false
|
|
3893
|
-
*/
|
|
3894
|
-
downlevelIteration?: boolean;
|
|
3895
|
-
|
|
3896
|
-
/**
|
|
3897
|
-
Report errors in `.js` files.
|
|
3898
|
-
|
|
3899
|
-
@default false
|
|
3900
|
-
*/
|
|
3901
|
-
checkJs?: boolean;
|
|
3902
|
-
|
|
3903
|
-
/**
|
|
3904
|
-
Built-in iterators are instantiated with a `TReturn` type of undefined instead of `any`.
|
|
3905
|
-
|
|
3906
|
-
@default false
|
|
3907
|
-
*/
|
|
3908
|
-
strictBuiltinIteratorReturn?: boolean;
|
|
3909
|
-
|
|
3910
|
-
/**
|
|
3911
|
-
Disable bivariant parameter checking for function types.
|
|
3912
|
-
|
|
3913
|
-
@default false
|
|
3914
|
-
*/
|
|
3915
|
-
strictFunctionTypes?: boolean;
|
|
3916
|
-
|
|
3917
|
-
/**
|
|
3918
|
-
Ensure non-undefined class properties are initialized in the constructor.
|
|
3919
|
-
|
|
3920
|
-
@default false
|
|
3921
|
-
*/
|
|
3922
|
-
strictPropertyInitialization?: boolean;
|
|
3923
|
-
|
|
3924
|
-
/**
|
|
3925
|
-
Emit `__importStar` and `__importDefault` helpers for runtime Babel ecosystem compatibility and enable `--allowSyntheticDefaultImports` for typesystem compatibility.
|
|
3926
|
-
|
|
3927
|
-
@default false
|
|
3928
|
-
*/
|
|
3929
|
-
esModuleInterop?: boolean;
|
|
3930
|
-
|
|
3931
|
-
/**
|
|
3932
|
-
Allow accessing UMD globals from modules.
|
|
3933
|
-
|
|
3934
|
-
@default false
|
|
3935
|
-
*/
|
|
3936
|
-
allowUmdGlobalAccess?: boolean;
|
|
3937
|
-
|
|
3938
|
-
/**
|
|
3939
|
-
Resolve `keyof` to string valued property names only (no numbers or symbols).
|
|
3940
|
-
|
|
3941
|
-
@default false
|
|
3942
|
-
@deprecated This option will be removed in TypeScript 5.5.
|
|
3943
|
-
*/
|
|
3944
|
-
keyofStringsOnly?: boolean;
|
|
3945
|
-
|
|
3946
|
-
/**
|
|
3947
|
-
Emit ECMAScript standard class fields.
|
|
3948
|
-
|
|
3949
|
-
@default false
|
|
3950
|
-
*/
|
|
3951
|
-
useDefineForClassFields?: boolean;
|
|
3952
|
-
|
|
3953
|
-
/**
|
|
3954
|
-
Generates a sourcemap for each corresponding `.d.ts` file.
|
|
3955
|
-
|
|
3956
|
-
@default false
|
|
3957
|
-
*/
|
|
3958
|
-
declarationMap?: boolean;
|
|
3959
|
-
|
|
3960
|
-
/**
|
|
3961
|
-
Include modules imported with `.json` extension.
|
|
3962
|
-
|
|
3963
|
-
@default false
|
|
3964
|
-
*/
|
|
3965
|
-
resolveJsonModule?: boolean;
|
|
3966
|
-
|
|
3967
|
-
/**
|
|
3968
|
-
Have recompiles in '--incremental' and '--watch' assume that changes within a file will only affect files directly depending on it.
|
|
3969
|
-
|
|
3970
|
-
@default false
|
|
3971
|
-
*/
|
|
3972
|
-
assumeChangesOnlyAffectDirectDependencies?: boolean;
|
|
3973
|
-
|
|
3974
|
-
/**
|
|
3975
|
-
Output more detailed compiler performance information after building.
|
|
3976
|
-
|
|
3977
|
-
@default false
|
|
3978
|
-
*/
|
|
3979
|
-
extendedDiagnostics?: boolean;
|
|
3980
|
-
|
|
3981
|
-
/**
|
|
3982
|
-
Print names of files that are part of the compilation and then stop processing.
|
|
3983
|
-
|
|
3984
|
-
@default false
|
|
3985
|
-
*/
|
|
3986
|
-
listFilesOnly?: boolean;
|
|
3987
|
-
|
|
3988
|
-
/**
|
|
3989
|
-
Disable preferring source files instead of declaration files when referencing composite projects.
|
|
3990
|
-
|
|
3991
|
-
@default true if composite, false otherwise
|
|
3992
|
-
*/
|
|
3993
|
-
disableSourceOfProjectReferenceRedirect?: boolean;
|
|
3994
|
-
|
|
3995
|
-
/**
|
|
3996
|
-
Opt a project out of multi-project reference checking when editing.
|
|
3997
|
-
|
|
3998
|
-
@default false
|
|
3999
|
-
*/
|
|
4000
|
-
disableSolutionSearching?: boolean;
|
|
4001
|
-
|
|
4002
|
-
/**
|
|
4003
|
-
Print names of files which TypeScript sees as a part of your project and the reason they are part of the compilation.
|
|
4004
|
-
|
|
4005
|
-
@default false
|
|
4006
|
-
*/
|
|
4007
|
-
explainFiles?: boolean;
|
|
4008
|
-
|
|
4009
|
-
/**
|
|
4010
|
-
Preserve unused imported values in the JavaScript output that would otherwise be removed.
|
|
4011
|
-
|
|
4012
|
-
@default true
|
|
4013
|
-
@deprecated Use `verbatimModuleSyntax` instead.
|
|
4014
|
-
*/
|
|
4015
|
-
preserveValueImports?: boolean;
|
|
4016
|
-
|
|
4017
|
-
/**
|
|
4018
|
-
List of file name suffixes to search when resolving a module.
|
|
4019
|
-
*/
|
|
4020
|
-
moduleSuffixes?: string[];
|
|
4021
|
-
|
|
4022
|
-
/**
|
|
4023
|
-
Control what method is used to detect module-format JS files.
|
|
4024
|
-
|
|
4025
|
-
@default 'auto'
|
|
4026
|
-
*/
|
|
4027
|
-
moduleDetection?: CompilerOptions.ModuleDetection;
|
|
4028
|
-
|
|
4029
|
-
/**
|
|
4030
|
-
Allows TypeScript files to import each other with a TypeScript-specific extension like .ts, .mts, or .tsx.
|
|
4031
|
-
|
|
4032
|
-
@default false
|
|
4033
|
-
*/
|
|
4034
|
-
allowImportingTsExtensions?: boolean;
|
|
4035
|
-
|
|
4036
|
-
/**
|
|
4037
|
-
Forces TypeScript to consult the exports field of package.json files if it ever reads from a package in node_modules.
|
|
4038
|
-
|
|
4039
|
-
@default false
|
|
4040
|
-
*/
|
|
4041
|
-
resolvePackageJsonExports?: boolean;
|
|
4042
|
-
|
|
4043
|
-
/**
|
|
4044
|
-
Forces TypeScript to consult the imports field of package.json files when performing a lookup that starts with # from a file whose ancestor directory contains a package.json.
|
|
4045
|
-
|
|
4046
|
-
@default false
|
|
4047
|
-
*/
|
|
4048
|
-
resolvePackageJsonImports?: boolean;
|
|
4049
|
-
|
|
4050
|
-
/**
|
|
4051
|
-
Suppress errors for file formats that TypeScript does not understand.
|
|
4052
|
-
|
|
4053
|
-
@default false
|
|
4054
|
-
*/
|
|
4055
|
-
allowArbitraryExtensions?: boolean;
|
|
4056
|
-
|
|
4057
|
-
/**
|
|
4058
|
-
List of additional conditions that should succeed when TypeScript resolves from package.json.
|
|
4059
|
-
*/
|
|
4060
|
-
customConditions?: string[];
|
|
4061
|
-
|
|
4062
|
-
/**
|
|
4063
|
-
Anything that uses the type modifier is dropped entirely.
|
|
4064
|
-
|
|
4065
|
-
@default false
|
|
4066
|
-
*/
|
|
4067
|
-
verbatimModuleSyntax?: boolean;
|
|
4068
|
-
|
|
4069
|
-
/**
|
|
4070
|
-
Suppress deprecation warnings
|
|
4071
|
-
*/
|
|
4072
|
-
ignoreDeprecations?: CompilerOptions.IgnoreDeprecations;
|
|
4073
|
-
|
|
4074
|
-
/**
|
|
4075
|
-
Do not allow runtime constructs that are not part of ECMAScript.
|
|
4076
|
-
|
|
4077
|
-
@default false
|
|
4078
|
-
*/
|
|
4079
|
-
erasableSyntaxOnly?: boolean;
|
|
4080
|
-
|
|
4081
|
-
/**
|
|
4082
|
-
Enable lib replacement.
|
|
4083
|
-
|
|
4084
|
-
@default true
|
|
4085
|
-
*/
|
|
4086
|
-
libReplacement?: boolean;
|
|
4087
|
-
};
|
|
4088
|
-
|
|
4089
|
-
namespace WatchOptions {
|
|
4090
|
-
export type WatchFileKind =
|
|
4091
|
-
| 'FixedPollingInterval'
|
|
4092
|
-
| 'PriorityPollingInterval'
|
|
4093
|
-
| 'DynamicPriorityPolling'
|
|
4094
|
-
| 'FixedChunkSizePolling'
|
|
4095
|
-
| 'UseFsEvents'
|
|
4096
|
-
| 'UseFsEventsOnParentDirectory';
|
|
4097
|
-
|
|
4098
|
-
export type WatchDirectoryKind =
|
|
4099
|
-
| 'UseFsEvents'
|
|
4100
|
-
| 'FixedPollingInterval'
|
|
4101
|
-
| 'DynamicPriorityPolling'
|
|
4102
|
-
| 'FixedChunkSizePolling';
|
|
4103
|
-
|
|
4104
|
-
export type PollingWatchKind =
|
|
4105
|
-
| 'FixedInterval'
|
|
4106
|
-
| 'PriorityInterval'
|
|
4107
|
-
| 'DynamicPriority'
|
|
4108
|
-
| 'FixedChunkSize';
|
|
4109
|
-
}
|
|
4110
|
-
|
|
4111
|
-
export type WatchOptions = {
|
|
4112
|
-
|
|
4113
|
-
/**
|
|
4114
|
-
Specify the strategy for watching individual files.
|
|
4115
|
-
|
|
4116
|
-
@default 'UseFsEvents'
|
|
4117
|
-
*/
|
|
4118
|
-
watchFile?: WatchOptions.WatchFileKind | Lowercase<WatchOptions.WatchFileKind>;
|
|
4119
|
-
|
|
4120
|
-
/**
|
|
4121
|
-
Specify the strategy for watching directories under systems that lack recursive file-watching functionality.
|
|
4122
|
-
|
|
4123
|
-
@default 'UseFsEvents'
|
|
4124
|
-
*/
|
|
4125
|
-
watchDirectory?: WatchOptions.WatchDirectoryKind | Lowercase<WatchOptions.WatchDirectoryKind>;
|
|
4126
|
-
|
|
4127
|
-
/**
|
|
4128
|
-
Specify the polling strategy to use when the system runs out of or doesn't support native file watchers.
|
|
4129
|
-
*/
|
|
4130
|
-
fallbackPolling?: WatchOptions.PollingWatchKind | Lowercase<WatchOptions.PollingWatchKind>;
|
|
4131
|
-
|
|
4132
|
-
/**
|
|
4133
|
-
Enable synchronous updates on directory watchers for platforms that don't support recursive watching natively.
|
|
4134
|
-
*/
|
|
4135
|
-
synchronousWatchDirectory?: boolean;
|
|
4136
|
-
|
|
4137
|
-
/**
|
|
4138
|
-
Specifies a list of directories to exclude from watch.
|
|
4139
|
-
*/
|
|
4140
|
-
excludeDirectories?: string[];
|
|
4141
|
-
|
|
4142
|
-
/**
|
|
4143
|
-
Specifies a list of files to exclude from watch.
|
|
4144
|
-
*/
|
|
4145
|
-
excludeFiles?: string[];
|
|
4146
|
-
};
|
|
4147
|
-
|
|
4148
|
-
/**
|
|
4149
|
-
Auto type (.d.ts) acquisition options for this project.
|
|
4150
|
-
*/
|
|
4151
|
-
export type TypeAcquisition = {
|
|
4152
|
-
/**
|
|
4153
|
-
Enable auto type acquisition.
|
|
4154
|
-
*/
|
|
4155
|
-
enable?: boolean;
|
|
4156
|
-
|
|
4157
|
-
/**
|
|
4158
|
-
Specifies a list of type declarations to be included in auto type acquisition. For example, `['jquery', 'lodash']`.
|
|
4159
|
-
*/
|
|
4160
|
-
include?: string[];
|
|
4161
|
-
|
|
4162
|
-
/**
|
|
4163
|
-
Specifies a list of type declarations to be excluded from auto type acquisition. For example, `['jquery', 'lodash']`.
|
|
4164
|
-
*/
|
|
4165
|
-
exclude?: string[];
|
|
4166
|
-
|
|
4167
|
-
/**
|
|
4168
|
-
Disable infering what types should be added based on filenames in a project.
|
|
4169
|
-
*/
|
|
4170
|
-
disableFilenameBasedTypeAcquisition?: boolean;
|
|
4171
|
-
};
|
|
4172
|
-
|
|
4173
|
-
export type References = {
|
|
4174
|
-
/**
|
|
4175
|
-
A normalized path on disk.
|
|
4176
|
-
*/
|
|
4177
|
-
path: string;
|
|
4178
|
-
|
|
4179
|
-
/**
|
|
4180
|
-
The path as the user originally wrote it.
|
|
4181
|
-
*/
|
|
4182
|
-
originalPath?: string;
|
|
4183
|
-
|
|
4184
|
-
/**
|
|
4185
|
-
True if the output of this reference should be prepended to the output of this project.
|
|
4186
|
-
|
|
4187
|
-
Only valid for `--outFile` compilations.
|
|
4188
|
-
@deprecated This option will be removed in TypeScript 5.5.
|
|
4189
|
-
*/
|
|
4190
|
-
prepend?: boolean;
|
|
4191
|
-
|
|
4192
|
-
/**
|
|
4193
|
-
True if it is intended that this reference form a circularity.
|
|
4194
|
-
*/
|
|
4195
|
-
circular?: boolean;
|
|
4196
|
-
};
|
|
4197
|
-
}
|
|
4198
|
-
|
|
4199
|
-
/**
|
|
4200
|
-
Type for [TypeScript's `tsconfig.json` file](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) (TypeScript 3.7).
|
|
4201
|
-
|
|
4202
|
-
@category File
|
|
4203
|
-
*/
|
|
4204
|
-
type TsConfigJson = {
|
|
4205
|
-
/**
|
|
4206
|
-
Instructs the TypeScript compiler how to compile `.ts` files.
|
|
4207
|
-
*/
|
|
4208
|
-
compilerOptions?: TsConfigJson.CompilerOptions;
|
|
4209
|
-
|
|
4210
|
-
/**
|
|
4211
|
-
Instructs the TypeScript compiler how to watch files.
|
|
4212
|
-
*/
|
|
4213
|
-
watchOptions?: TsConfigJson.WatchOptions;
|
|
4214
|
-
|
|
4215
|
-
/**
|
|
4216
|
-
Auto type (.d.ts) acquisition options for this project.
|
|
4217
|
-
*/
|
|
4218
|
-
typeAcquisition?: TsConfigJson.TypeAcquisition;
|
|
4219
|
-
|
|
4220
|
-
/**
|
|
4221
|
-
Enable Compile-on-Save for this project.
|
|
4222
|
-
*/
|
|
4223
|
-
compileOnSave?: boolean;
|
|
4224
|
-
|
|
4225
|
-
/**
|
|
4226
|
-
Path to base configuration file to inherit from.
|
|
4227
|
-
*/
|
|
4228
|
-
extends?: string | string[];
|
|
4229
|
-
|
|
4230
|
-
/**
|
|
4231
|
-
If no `files` or `include` property is present in a `tsconfig.json`, the compiler defaults to including all files in the containing directory and subdirectories except those specified by `exclude`. When a `files` property is specified, only those files and those specified by `include` are included.
|
|
4232
|
-
*/
|
|
4233
|
-
files?: string[];
|
|
4234
|
-
|
|
4235
|
-
/**
|
|
4236
|
-
Specifies a list of files to be excluded from compilation. The `exclude` property only affects the files included via the `include` property and not the `files` property.
|
|
4237
|
-
|
|
4238
|
-
Glob patterns require TypeScript version 2.0 or later.
|
|
4239
|
-
*/
|
|
4240
|
-
exclude?: string[];
|
|
4241
|
-
|
|
4242
|
-
/**
|
|
4243
|
-
Specifies a list of glob patterns that match files to be included in compilation.
|
|
4244
|
-
|
|
4245
|
-
If no `files` or `include` property is present in a `tsconfig.json`, the compiler defaults to including all files in the containing directory and subdirectories except those specified by `exclude`.
|
|
4246
|
-
*/
|
|
4247
|
-
include?: string[];
|
|
4248
|
-
|
|
4249
|
-
/**
|
|
4250
|
-
Referenced projects.
|
|
4251
|
-
*/
|
|
4252
|
-
references?: TsConfigJson.References[];
|
|
4253
|
-
};
|
|
4254
|
-
|
|
4255
|
-
type TsConfigJsonResolved = Except<TsConfigJson, "extends">;
|
|
4256
|
-
type TsConfigResult = {
|
|
4257
|
-
config: TsConfigJsonResolved;
|
|
4258
|
-
path: string;
|
|
4259
|
-
};
|
|
4260
|
-
|
|
4261
|
-
type TsconfigPathsPluginOptions = {
|
|
4262
|
-
resolveAbsolutePath?: boolean;
|
|
4263
|
-
};
|
|
4264
|
-
declare const resolveTsconfigPathsPlugin: (rootDirectory: string, tsconfig: TsConfigResult, logger: PailServerType, pluginOptions: TsconfigPathsPluginOptions) => Plugin$1;
|
|
4265
|
-
|
|
4266
|
-
interface RollupDynamicImportVariablesOptions {
|
|
4267
|
-
errorWhenNoFilesFound?: boolean;
|
|
4268
|
-
exclude?: FilterPattern;
|
|
4269
|
-
include?: FilterPattern;
|
|
4270
|
-
warnOnError?: boolean;
|
|
4271
|
-
}
|
|
4272
|
-
interface IsolatedDeclarationsResult {
|
|
4273
|
-
errors: string[];
|
|
4274
|
-
map?: string;
|
|
4275
|
-
sourceText: string;
|
|
4276
|
-
}
|
|
4277
|
-
type IsolatedDeclarationsTransformer = (code: string, id: string, sourceMap?: boolean) => Promise<IsolatedDeclarationsResult>;
|
|
4278
|
-
interface PackemRollupOptions {
|
|
4279
|
-
alias: RollupAliasOptions | false;
|
|
4280
|
-
cjsInterop?: CJSInteropOptions;
|
|
4281
|
-
commonjs: RollupCommonJSOptions | false;
|
|
4282
|
-
copy?: CopyPluginOptions | false;
|
|
4283
|
-
dataUri?: DataUriPluginOptions | false;
|
|
4284
|
-
debarrel?: DebarrelPluginOptions | false;
|
|
4285
|
-
dts: Options$4;
|
|
4286
|
-
dynamicVars?: RollupDynamicImportVariablesOptions | false;
|
|
4287
|
-
esbuild?: Options$1 | false;
|
|
4288
|
-
experimental?: {
|
|
4289
|
-
resolve?: OxcResolveOptions | false;
|
|
4290
|
-
};
|
|
4291
|
-
isolatedDeclarations?: IsolatedDeclarationsOptions;
|
|
4292
|
-
json: RollupJsonOptions | false;
|
|
4293
|
-
jsxRemoveAttributes?: JSXRemoveAttributesPlugin | false;
|
|
4294
|
-
license?: LicenseOptions | false;
|
|
4295
|
-
metafile?: boolean;
|
|
4296
|
-
minifyHTMLLiterals?: MinifyHTMLLiteralsOptions | false;
|
|
4297
|
-
nativeModules?: NativeModulesOptions | false;
|
|
4298
|
-
output?: OutputOptions;
|
|
4299
|
-
oxc?: Omit<OXCTransformPluginConfig, "cwd" | "sourcemap" | "target"> | false;
|
|
4300
|
-
patchTypes: PatchTypesOptions | false;
|
|
4301
|
-
pluginPure?: Omit<PureAnnotationsOptions, "sourcemap"> | false;
|
|
4302
|
-
plugins?: RollupPlugins;
|
|
4303
|
-
polyfillNode?: NodePolyfillsOptions | false;
|
|
4304
|
-
preserveDirectives?: {
|
|
4305
|
-
directiveRegex?: RegExp;
|
|
4306
|
-
exclude?: FilterPattern;
|
|
4307
|
-
include?: FilterPattern;
|
|
4308
|
-
};
|
|
4309
|
-
preserveDynamicImports?: boolean;
|
|
4310
|
-
raw?: RawLoaderOptions | false;
|
|
4311
|
-
replace: Omit<RollupReplaceOptions, "cwd"> | false;
|
|
4312
|
-
requireCJS?: Options$2 | false;
|
|
4313
|
-
resolve: RollupNodeResolveOptions | false;
|
|
4314
|
-
shebang?: Partial<ShebangOptions> | false;
|
|
4315
|
-
shim?: EsmShimCjsSyntaxOptions | false;
|
|
4316
|
-
sourcemap?: SourcemapsPluginOptions;
|
|
4317
|
-
sucrase?: SucrasePluginConfig | false;
|
|
4318
|
-
swc?: SwcPluginConfig | false;
|
|
4319
|
-
treeshake?: RollupOptions["treeshake"];
|
|
4320
|
-
tsconfigPaths?: TsconfigPathsPluginOptions | false;
|
|
4321
|
-
url?: UrlOptions | false;
|
|
4322
|
-
visualizer?: PluginVisualizerOptions | false;
|
|
4323
|
-
wasm?: RollupWasmOptions | false;
|
|
4324
|
-
watch?: RollupOptions["watch"];
|
|
4325
|
-
}
|
|
4326
|
-
type RollupPlugins = {
|
|
4327
|
-
enforce?: "post" | "pre";
|
|
4328
|
-
plugin: Plugin$1;
|
|
4329
|
-
type?: "build" | "dts";
|
|
4330
|
-
}[];
|
|
4331
|
-
type TransformerFn = ((config: EsbuildPluginConfig | InternalOXCTransformPluginConfig | SucrasePluginConfig | SwcPluginConfig) => Plugin$1) & {
|
|
4332
|
-
NAME?: TransformerName;
|
|
4333
|
-
};
|
|
4334
|
-
type TransformerName = "esbuild" | "oxc" | "sucrase" | "swc";
|
|
4335
|
-
|
|
4336
|
-
export { sucrasePlugin as $, patchTypescriptTypes as Q, resolveTsconfigPathsPlugin as W, copyPlugin as b, cjsInteropPlugin as c, dataUriPlugin as d, debarrelPlugin as f, esmShimCjsSyntaxPlugin as g, requireCJSTransformerPlugin as h, isolatedDeclarationsPlugin as i, jsxRemoveAttributes as j, getShebang as k, license as l, makeExecutable as m, nativeModulesPlugin as n, removeShebangPlugin as o, sourcemapsPlugin as q, rawPlugin as r, shebangPlugin as s, urlPlugin as u };
|
|
4337
|
-
export type { Optimized as A, OptimizeDepsOptions as B, CJSInteropOptions as C, DataUriPluginOptions as D, EsmShimCjsSyntaxOptions as E, OptimizeDepsResult as F, Options$1 as G, SwcPluginConfig as H, IsolatedDeclarationsOptions as I, JSXRemoveAttributesPlugin as J, TsConfigResult as K, LicenseOptions as L, PatchTypesOptions as M, NativeModulesOptions as N, Options$2 as O, PackemRollupOptions as P, RawLoaderOptions as R, ShebangOptions as S, TransformFunction as T, UrlOptions as U, TsconfigPathsPluginOptions as V, OxcResolveOptions as X, InternalOXCTransformPluginConfig as Y, OXCTransformPluginConfig as Z, SucrasePluginConfig as _, CopyPluginOptions as a, DebarrelPluginOptions as e, SourcemapsPluginOptions as p, IsolatedDeclarationsResult as t, IsolatedDeclarationsTransformer as v, RollupPlugins as w, TransformerFn as x, TransformerName as y, EsbuildPluginConfig as z };
|