@visulima/packem-rollup 1.0.0-alpha.3 → 1.0.0-alpha.30

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