@visulima/packem-rollup 1.0.0-alpha.7 → 1.0.0-alpha.71

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