@visulima/packem-rollup 1.0.0-alpha.1

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