@rspack/core 1.0.14 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiled/@swc/types/index.d.ts +1962 -0
- package/compiled/@swc/types/index.js +19 -0
- package/compiled/@swc/types/license +201 -0
- package/compiled/@swc/types/package.json +1 -0
- package/compiled/enhanced-resolve/CachedInputFileSystem.js +267 -80
- package/compiled/enhanced-resolve/index.d.ts +849 -236
- package/compiled/enhanced-resolve/package.json +1 -1
- package/compiled/graceful-fs/index.js +10 -10
- package/compiled/graceful-fs/package.json +1 -1
- package/compiled/zod/index.d.ts +2 -2
- package/dist/Compilation.d.ts +7 -18
- package/dist/DependenciesBlock.d.ts +6 -4
- package/dist/FileSystem.d.ts +7 -2
- package/dist/Module.d.ts +17 -14
- package/dist/builtin-loader/swc/types.d.ts +9 -435
- package/dist/builtin-plugin/EntryPlugin.d.ts +14 -11
- package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +10 -10
- package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +1 -1
- package/dist/builtin-plugin/MangleExportsPlugin.d.ts +10 -10
- package/dist/builtin-plugin/ModuleConcatenationPlugin.d.ts +8 -10
- package/dist/builtin-plugin/RemoveDuplicateModulesPlugin.d.ts +10 -0
- package/dist/builtin-plugin/SizeLimitsPlugin.d.ts +8 -8
- package/dist/builtin-plugin/SplitChunksPlugin.d.ts +1 -1
- package/dist/builtin-plugin/index.d.ts +4 -2
- package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +3 -3
- package/dist/builtin-plugin/lazy-compilation/plugin.d.ts +3 -3
- package/dist/config/adapter.d.ts +1 -1
- package/dist/config/adapterRuleUse.d.ts +1 -1
- package/dist/config/index.d.ts +1 -0
- package/dist/config/normalization.d.ts +4 -11
- package/dist/config/types.d.ts +417 -9
- package/dist/config/zod.d.ts +1044 -1303
- package/dist/exports.d.ts +4 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1023 -5103
- package/dist/util/ArrayQueue.d.ts +1 -9
- package/dist/util/asyncLib.d.ts +54 -0
- package/package.json +9 -9
- package/dist/builtin-loader/swc/react.d.ts +0 -15
- package/dist/lib/Dependency.d.ts +0 -23
- package/dist/lib/formatLocation.d.ts +0 -16
- package/dist/logging/runtime.d.ts +0 -16
- package/dist/util/IterableHelpers.d.ts +0 -12
- package/dist/util/scheme.d.ts +0 -6
- package/dist/util/webpack.d.ts +0 -4
- /package/dist/builtin-plugin/{LightningCssMiminizerRspackPlugin.d.ts → LightningCssMinimizerRspackPlugin.d.ts} +0 -0
|
@@ -0,0 +1,1962 @@
|
|
|
1
|
+
export interface Plugin {
|
|
2
|
+
(module: Program): Program;
|
|
3
|
+
}
|
|
4
|
+
export type ParseOptions = ParserConfig & {
|
|
5
|
+
comments?: boolean;
|
|
6
|
+
script?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Defaults to es3.
|
|
9
|
+
*/
|
|
10
|
+
target?: JscTarget;
|
|
11
|
+
};
|
|
12
|
+
export type TerserEcmaVersion = 5 | 2015 | 2016 | string | number;
|
|
13
|
+
export interface JsMinifyOptions {
|
|
14
|
+
compress?: TerserCompressOptions | boolean;
|
|
15
|
+
format?: JsFormatOptions & ToSnakeCaseProperties<JsFormatOptions>;
|
|
16
|
+
mangle?: TerserMangleOptions | boolean;
|
|
17
|
+
ecma?: TerserEcmaVersion;
|
|
18
|
+
keep_classnames?: boolean;
|
|
19
|
+
keep_fnames?: boolean;
|
|
20
|
+
module?: boolean | "unknown";
|
|
21
|
+
safari10?: boolean;
|
|
22
|
+
toplevel?: boolean;
|
|
23
|
+
sourceMap?: boolean;
|
|
24
|
+
outputPath?: string;
|
|
25
|
+
inlineSourcesContent?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @example ToSnakeCase<'indentLevel'> == 'indent_level'
|
|
29
|
+
*/
|
|
30
|
+
type ToSnakeCase<T extends string> = T extends `${infer A}${infer B}` ? `${A extends Lowercase<A> ? A : `_${Lowercase<A>}`}${ToSnakeCase<B>}` : T;
|
|
31
|
+
/**
|
|
32
|
+
* @example ToSnakeCaseProperties<{indentLevel: 3}> == {indent_level: 3}
|
|
33
|
+
*/
|
|
34
|
+
type ToSnakeCaseProperties<T> = {
|
|
35
|
+
[K in keyof T as K extends string ? ToSnakeCase<K> : K]: T[K];
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* These properties are mostly not implemented yet,
|
|
39
|
+
* but it exists to support passing terser config to swc minify
|
|
40
|
+
* without modification.
|
|
41
|
+
*/
|
|
42
|
+
export interface JsFormatOptions {
|
|
43
|
+
/**
|
|
44
|
+
* Currently noop.
|
|
45
|
+
* @default false
|
|
46
|
+
* @alias ascii_only
|
|
47
|
+
*/
|
|
48
|
+
asciiOnly?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Currently noop.
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
beautify?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Currently noop.
|
|
56
|
+
* @default false
|
|
57
|
+
*/
|
|
58
|
+
braces?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* - `false`: removes all comments
|
|
61
|
+
* - `'some'`: preserves some comments
|
|
62
|
+
* - `'all'`: preserves all comments
|
|
63
|
+
* @default false
|
|
64
|
+
*/
|
|
65
|
+
comments?: false | "some" | "all";
|
|
66
|
+
/**
|
|
67
|
+
* Currently noop.
|
|
68
|
+
* @default 5
|
|
69
|
+
*/
|
|
70
|
+
ecma?: TerserEcmaVersion;
|
|
71
|
+
/**
|
|
72
|
+
* Currently noop.
|
|
73
|
+
* @alias indent_level
|
|
74
|
+
*/
|
|
75
|
+
indentLevel?: number;
|
|
76
|
+
/**
|
|
77
|
+
* Currently noop.
|
|
78
|
+
* @alias indent_start
|
|
79
|
+
*/
|
|
80
|
+
indentStart?: number;
|
|
81
|
+
/**
|
|
82
|
+
* Currently noop.
|
|
83
|
+
* @alias inline_script
|
|
84
|
+
*/
|
|
85
|
+
inlineScript?: number;
|
|
86
|
+
/**
|
|
87
|
+
* Currently noop.
|
|
88
|
+
* @alias keep_numbers
|
|
89
|
+
*/
|
|
90
|
+
keepNumbers?: number;
|
|
91
|
+
/**
|
|
92
|
+
* Currently noop.
|
|
93
|
+
* @alias keep_quoted_props
|
|
94
|
+
*/
|
|
95
|
+
keepQuotedProps?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Currently noop.
|
|
98
|
+
* @alias max_line_len
|
|
99
|
+
*/
|
|
100
|
+
maxLineLen?: number | false;
|
|
101
|
+
/**
|
|
102
|
+
* Currently noop.
|
|
103
|
+
*/
|
|
104
|
+
preamble?: string;
|
|
105
|
+
/**
|
|
106
|
+
* Currently noop.
|
|
107
|
+
* @alias quote_keys
|
|
108
|
+
*/
|
|
109
|
+
quoteKeys?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Currently noop.
|
|
112
|
+
* @alias quote_style
|
|
113
|
+
*/
|
|
114
|
+
quoteStyle?: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Currently noop.
|
|
117
|
+
* @alias preserve_annotations
|
|
118
|
+
*/
|
|
119
|
+
preserveAnnotations?: boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Currently noop.
|
|
122
|
+
*/
|
|
123
|
+
safari10?: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Currently noop.
|
|
126
|
+
*/
|
|
127
|
+
semicolons?: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Currently noop.
|
|
130
|
+
*/
|
|
131
|
+
shebang?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Currently noop.
|
|
134
|
+
*/
|
|
135
|
+
webkit?: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Currently noop.
|
|
138
|
+
* @alias wrap_iife
|
|
139
|
+
*/
|
|
140
|
+
wrapIife?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Currently noop.
|
|
143
|
+
* @alias wrap_func_args
|
|
144
|
+
*/
|
|
145
|
+
wrapFuncArgs?: boolean;
|
|
146
|
+
}
|
|
147
|
+
export interface TerserCompressOptions {
|
|
148
|
+
arguments?: boolean;
|
|
149
|
+
arrows?: boolean;
|
|
150
|
+
booleans?: boolean;
|
|
151
|
+
booleans_as_integers?: boolean;
|
|
152
|
+
collapse_vars?: boolean;
|
|
153
|
+
comparisons?: boolean;
|
|
154
|
+
computed_props?: boolean;
|
|
155
|
+
conditionals?: boolean;
|
|
156
|
+
dead_code?: boolean;
|
|
157
|
+
defaults?: boolean;
|
|
158
|
+
directives?: boolean;
|
|
159
|
+
drop_console?: boolean;
|
|
160
|
+
drop_debugger?: boolean;
|
|
161
|
+
ecma?: TerserEcmaVersion;
|
|
162
|
+
evaluate?: boolean;
|
|
163
|
+
expression?: boolean;
|
|
164
|
+
global_defs?: any;
|
|
165
|
+
hoist_funs?: boolean;
|
|
166
|
+
hoist_props?: boolean;
|
|
167
|
+
hoist_vars?: boolean;
|
|
168
|
+
ie8?: boolean;
|
|
169
|
+
if_return?: boolean;
|
|
170
|
+
inline?: 0 | 1 | 2 | 3;
|
|
171
|
+
join_vars?: boolean;
|
|
172
|
+
keep_classnames?: boolean;
|
|
173
|
+
keep_fargs?: boolean;
|
|
174
|
+
keep_fnames?: boolean;
|
|
175
|
+
keep_infinity?: boolean;
|
|
176
|
+
loops?: boolean;
|
|
177
|
+
negate_iife?: boolean;
|
|
178
|
+
passes?: number;
|
|
179
|
+
properties?: boolean;
|
|
180
|
+
pure_getters?: any;
|
|
181
|
+
pure_funcs?: string[];
|
|
182
|
+
reduce_funcs?: boolean;
|
|
183
|
+
reduce_vars?: boolean;
|
|
184
|
+
sequences?: any;
|
|
185
|
+
side_effects?: boolean;
|
|
186
|
+
switches?: boolean;
|
|
187
|
+
top_retain?: any;
|
|
188
|
+
toplevel?: any;
|
|
189
|
+
typeofs?: boolean;
|
|
190
|
+
unsafe?: boolean;
|
|
191
|
+
unsafe_passes?: boolean;
|
|
192
|
+
unsafe_arrows?: boolean;
|
|
193
|
+
unsafe_comps?: boolean;
|
|
194
|
+
unsafe_function?: boolean;
|
|
195
|
+
unsafe_math?: boolean;
|
|
196
|
+
unsafe_symbols?: boolean;
|
|
197
|
+
unsafe_methods?: boolean;
|
|
198
|
+
unsafe_proto?: boolean;
|
|
199
|
+
unsafe_regexp?: boolean;
|
|
200
|
+
unsafe_undefined?: boolean;
|
|
201
|
+
unused?: boolean;
|
|
202
|
+
const_to_let?: boolean;
|
|
203
|
+
module?: boolean;
|
|
204
|
+
}
|
|
205
|
+
export interface TerserMangleOptions {
|
|
206
|
+
props?: TerserManglePropertiesOptions;
|
|
207
|
+
/**
|
|
208
|
+
* Pass `true` to mangle names declared in the top level scope.
|
|
209
|
+
*/
|
|
210
|
+
topLevel?: boolean;
|
|
211
|
+
/**
|
|
212
|
+
* @deprecated An alias for compatibility with terser.
|
|
213
|
+
*/
|
|
214
|
+
toplevel?: boolean;
|
|
215
|
+
/**
|
|
216
|
+
* Pass `true` to not mangle class names.
|
|
217
|
+
*/
|
|
218
|
+
keepClassNames?: boolean;
|
|
219
|
+
/**
|
|
220
|
+
* @deprecated An alias for compatibility with terser.
|
|
221
|
+
*/
|
|
222
|
+
keep_classnames?: boolean;
|
|
223
|
+
/**
|
|
224
|
+
* Pass `true` to not mangle function names.
|
|
225
|
+
*/
|
|
226
|
+
keepFnNames?: boolean;
|
|
227
|
+
/**
|
|
228
|
+
* @deprecated An alias for compatibility with terser.
|
|
229
|
+
*/
|
|
230
|
+
keep_fnames?: boolean;
|
|
231
|
+
/**
|
|
232
|
+
* Pass `true` to not mangle private props.
|
|
233
|
+
*/
|
|
234
|
+
keepPrivateProps?: boolean;
|
|
235
|
+
/**
|
|
236
|
+
* @deprecated An alias for compatibility with terser.
|
|
237
|
+
*/
|
|
238
|
+
keep_private_props?: boolean;
|
|
239
|
+
ie8?: boolean;
|
|
240
|
+
safari10?: boolean;
|
|
241
|
+
reserved?: string[];
|
|
242
|
+
}
|
|
243
|
+
export interface TerserManglePropertiesOptions {
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Programmatic options.
|
|
247
|
+
*/
|
|
248
|
+
export interface Options extends Config {
|
|
249
|
+
/**
|
|
250
|
+
* If true, a file is parsed as a script instead of module.
|
|
251
|
+
*/
|
|
252
|
+
script?: boolean;
|
|
253
|
+
/**
|
|
254
|
+
* The working directory that all paths in the programmatic
|
|
255
|
+
* options will be resolved relative to.
|
|
256
|
+
*
|
|
257
|
+
* Defaults to `process.cwd()`.
|
|
258
|
+
*/
|
|
259
|
+
cwd?: string;
|
|
260
|
+
caller?: CallerOptions;
|
|
261
|
+
/** The filename associated with the code currently being compiled,
|
|
262
|
+
* if there is one. The filename is optional, but not all of Swc's
|
|
263
|
+
* functionality is available when the filename is unknown, because a
|
|
264
|
+
* subset of options rely on the filename for their functionality.
|
|
265
|
+
*
|
|
266
|
+
* The three primary cases users could run into are:
|
|
267
|
+
*
|
|
268
|
+
* - The filename is exposed to plugins. Some plugins may require the
|
|
269
|
+
* presence of the filename.
|
|
270
|
+
* - Options like "test", "exclude", and "ignore" require the filename
|
|
271
|
+
* for string/RegExp matching.
|
|
272
|
+
* - .swcrc files are loaded relative to the file being compiled.
|
|
273
|
+
* If this option is omitted, Swc will behave as if swcrc: false has been set.
|
|
274
|
+
*/
|
|
275
|
+
filename?: string;
|
|
276
|
+
/**
|
|
277
|
+
* The initial path that will be processed based on the "rootMode" to
|
|
278
|
+
* determine the conceptual root folder for the current Swc project.
|
|
279
|
+
* This is used in two primary cases:
|
|
280
|
+
*
|
|
281
|
+
* - The base directory when checking for the default "configFile" value
|
|
282
|
+
* - The default value for "swcrcRoots".
|
|
283
|
+
*
|
|
284
|
+
* Defaults to `opts.cwd`
|
|
285
|
+
*/
|
|
286
|
+
root?: string;
|
|
287
|
+
/**
|
|
288
|
+
* This option, combined with the "root" value, defines how Swc chooses
|
|
289
|
+
* its project root. The different modes define different ways that Swc
|
|
290
|
+
* can process the "root" value to get the final project root.
|
|
291
|
+
*
|
|
292
|
+
* "root" - Passes the "root" value through as unchanged.
|
|
293
|
+
* "upward" - Walks upward from the "root" directory, looking for a directory
|
|
294
|
+
* containing a swc.config.js file, and throws an error if a swc.config.js
|
|
295
|
+
* is not found.
|
|
296
|
+
* "upward-optional" - Walk upward from the "root" directory, looking for
|
|
297
|
+
* a directory containing a swc.config.js file, and falls back to "root"
|
|
298
|
+
* if a swc.config.js is not found.
|
|
299
|
+
*
|
|
300
|
+
*
|
|
301
|
+
* "root" is the default mode because it avoids the risk that Swc
|
|
302
|
+
* will accidentally load a swc.config.js that is entirely outside
|
|
303
|
+
* of the current project folder. If you use "upward-optional",
|
|
304
|
+
* be aware that it will walk up the directory structure all the
|
|
305
|
+
* way to the filesystem root, and it is always possible that someone
|
|
306
|
+
* will have a forgotten swc.config.js in their home directory,
|
|
307
|
+
* which could cause unexpected errors in your builds.
|
|
308
|
+
*
|
|
309
|
+
*
|
|
310
|
+
* Users with monorepo project structures that run builds/tests on a
|
|
311
|
+
* per-package basis may well want to use "upward" since monorepos
|
|
312
|
+
* often have a swc.config.js in the project root. Running Swc
|
|
313
|
+
* in a monorepo subdirectory without "upward", will cause Swc
|
|
314
|
+
* to skip loading any swc.config.js files in the project root,
|
|
315
|
+
* which can lead to unexpected errors and compilation failure.
|
|
316
|
+
*/
|
|
317
|
+
rootMode?: "root" | "upward" | "upward-optional";
|
|
318
|
+
/**
|
|
319
|
+
* The current active environment used during configuration loading.
|
|
320
|
+
* This value is used as the key when resolving "env" configs,
|
|
321
|
+
* and is also available inside configuration functions, plugins,
|
|
322
|
+
* and presets, via the api.env() function.
|
|
323
|
+
*
|
|
324
|
+
* Defaults to `process.env.SWC_ENV || process.env.NODE_ENV || "development"`
|
|
325
|
+
*/
|
|
326
|
+
envName?: string;
|
|
327
|
+
/**
|
|
328
|
+
* Defaults to searching for a default `.swcrc` file, but can
|
|
329
|
+
* be passed the path of any JS or JSON5 config file.
|
|
330
|
+
*
|
|
331
|
+
*
|
|
332
|
+
* NOTE: This option does not affect loading of .swcrc files,
|
|
333
|
+
* so while it may be tempting to do configFile: "./foo/.swcrc",
|
|
334
|
+
* it is not recommended. If the given .swcrc is loaded via the
|
|
335
|
+
* standard file-relative logic, you'll end up loading the same
|
|
336
|
+
* config file twice, merging it with itself. If you are linking
|
|
337
|
+
* a specific config file, it is recommended to stick with a
|
|
338
|
+
* naming scheme that is independent of the "swcrc" name.
|
|
339
|
+
*
|
|
340
|
+
* Defaults to `path.resolve(opts.root, ".swcrc")`
|
|
341
|
+
*/
|
|
342
|
+
configFile?: string | boolean;
|
|
343
|
+
/**
|
|
344
|
+
* true will enable searching for configuration files relative to the "filename" provided to Swc.
|
|
345
|
+
*
|
|
346
|
+
* A swcrc value passed in the programmatic options will override one set within a configuration file.
|
|
347
|
+
*
|
|
348
|
+
* Note: .swcrc files are only loaded if the current "filename" is inside of
|
|
349
|
+
* a package that matches one of the "swcrcRoots" packages.
|
|
350
|
+
*
|
|
351
|
+
*
|
|
352
|
+
* Defaults to true as long as the filename option has been specified
|
|
353
|
+
*/
|
|
354
|
+
swcrc?: boolean;
|
|
355
|
+
/**
|
|
356
|
+
* By default, Babel will only search for .babelrc files within the "root" package
|
|
357
|
+
* because otherwise Babel cannot know if a given .babelrc is meant to be loaded,
|
|
358
|
+
* or if it's "plugins" and "presets" have even been installed, since the file
|
|
359
|
+
* being compiled could be inside node_modules, or have been symlinked into the project.
|
|
360
|
+
*
|
|
361
|
+
*
|
|
362
|
+
* This option allows users to provide a list of other packages that should be
|
|
363
|
+
* considered "root" packages when considering whether to load .babelrc files.
|
|
364
|
+
*
|
|
365
|
+
*
|
|
366
|
+
* For example, a monorepo setup that wishes to allow individual packages
|
|
367
|
+
* to have their own configs might want to do
|
|
368
|
+
*
|
|
369
|
+
*
|
|
370
|
+
*
|
|
371
|
+
* Defaults to `opts.root`
|
|
372
|
+
*/
|
|
373
|
+
swcrcRoots?: boolean | MatchPattern | MatchPattern[];
|
|
374
|
+
/**
|
|
375
|
+
* `true` will attempt to load an input sourcemap from the file itself, if it
|
|
376
|
+
* contains a //# sourceMappingURL=... comment. If no map is found, or the
|
|
377
|
+
* map fails to load and parse, it will be silently discarded.
|
|
378
|
+
*
|
|
379
|
+
* If an object is provided, it will be treated as the source map object itself.
|
|
380
|
+
*
|
|
381
|
+
* Defaults to `true`.
|
|
382
|
+
*/
|
|
383
|
+
inputSourceMap?: boolean | string;
|
|
384
|
+
/**
|
|
385
|
+
* The name to use for the file inside the source map object.
|
|
386
|
+
*
|
|
387
|
+
* Defaults to `path.basename(opts.filenameRelative)` when available, or `"unknown"`.
|
|
388
|
+
*/
|
|
389
|
+
sourceFileName?: string;
|
|
390
|
+
/**
|
|
391
|
+
* The sourceRoot fields to set in the generated source map, if one is desired.
|
|
392
|
+
*/
|
|
393
|
+
sourceRoot?: string;
|
|
394
|
+
plugin?: Plugin;
|
|
395
|
+
isModule?: boolean | "unknown";
|
|
396
|
+
/**
|
|
397
|
+
* Destination path. Note that this value is used only to fix source path
|
|
398
|
+
* of source map files and swc does not write output to this path.
|
|
399
|
+
*/
|
|
400
|
+
outputPath?: string;
|
|
401
|
+
}
|
|
402
|
+
export interface CallerOptions {
|
|
403
|
+
name: string;
|
|
404
|
+
[key: string]: any;
|
|
405
|
+
}
|
|
406
|
+
export type Swcrc = Config | Config[];
|
|
407
|
+
/**
|
|
408
|
+
* .swcrc
|
|
409
|
+
*/
|
|
410
|
+
export interface Config {
|
|
411
|
+
/**
|
|
412
|
+
* Note: The type is string because it follows rust's regex syntax.
|
|
413
|
+
*/
|
|
414
|
+
test?: string | string[];
|
|
415
|
+
/**
|
|
416
|
+
* Note: The type is string because it follows rust's regex syntax.
|
|
417
|
+
*/
|
|
418
|
+
exclude?: string | string[];
|
|
419
|
+
env?: EnvConfig;
|
|
420
|
+
jsc?: JscConfig;
|
|
421
|
+
module?: ModuleConfig;
|
|
422
|
+
minify?: boolean;
|
|
423
|
+
/**
|
|
424
|
+
* - true to generate a sourcemap for the code and include it in the result object.
|
|
425
|
+
* - "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.
|
|
426
|
+
*
|
|
427
|
+
* `swc-cli` overloads some of these to also affect how maps are written to disk:
|
|
428
|
+
*
|
|
429
|
+
* - true will write the map to a .map file on disk
|
|
430
|
+
* - "inline" will write the file directly, so it will have a data: containing the map
|
|
431
|
+
* - Note: These options are bit weird, so it may make the most sense to just use true
|
|
432
|
+
* and handle the rest in your own code, depending on your use case.
|
|
433
|
+
*/
|
|
434
|
+
sourceMaps?: boolean | "inline";
|
|
435
|
+
inlineSourcesContent?: boolean;
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Configuration ported from babel-preset-env
|
|
439
|
+
*/
|
|
440
|
+
export interface EnvConfig {
|
|
441
|
+
mode?: "usage" | "entry";
|
|
442
|
+
debug?: boolean;
|
|
443
|
+
dynamicImport?: boolean;
|
|
444
|
+
loose?: boolean;
|
|
445
|
+
/**
|
|
446
|
+
* Transpiles the broken syntax to the closest non-broken modern syntax
|
|
447
|
+
*
|
|
448
|
+
* Defaults to false.
|
|
449
|
+
*/
|
|
450
|
+
bugfixes?: boolean;
|
|
451
|
+
skip?: string[];
|
|
452
|
+
include?: string[];
|
|
453
|
+
exclude?: string[];
|
|
454
|
+
/**
|
|
455
|
+
* The version of the used core js.
|
|
456
|
+
*
|
|
457
|
+
*/
|
|
458
|
+
coreJs?: string;
|
|
459
|
+
targets?: any;
|
|
460
|
+
path?: string;
|
|
461
|
+
shippedProposals?: boolean;
|
|
462
|
+
/**
|
|
463
|
+
* Enable all transforms
|
|
464
|
+
*/
|
|
465
|
+
forceAllTransforms?: boolean;
|
|
466
|
+
}
|
|
467
|
+
export interface JscConfig {
|
|
468
|
+
loose?: boolean;
|
|
469
|
+
/**
|
|
470
|
+
* Defaults to EsParserConfig
|
|
471
|
+
*/
|
|
472
|
+
parser?: ParserConfig;
|
|
473
|
+
transform?: TransformConfig;
|
|
474
|
+
/**
|
|
475
|
+
* Use `@swc/helpers` instead of inline helpers.
|
|
476
|
+
*/
|
|
477
|
+
externalHelpers?: boolean;
|
|
478
|
+
/**
|
|
479
|
+
* Defaults to `es3` (which enabled **all** pass).
|
|
480
|
+
*/
|
|
481
|
+
target?: JscTarget;
|
|
482
|
+
/**
|
|
483
|
+
* Keep class names.
|
|
484
|
+
*/
|
|
485
|
+
keepClassNames?: boolean;
|
|
486
|
+
/**
|
|
487
|
+
* This is experimental, and can be removed without a major version bump.
|
|
488
|
+
*/
|
|
489
|
+
experimental?: {
|
|
490
|
+
optimizeHygiene?: boolean;
|
|
491
|
+
/**
|
|
492
|
+
* Preserve `with` in imports and exports.
|
|
493
|
+
*/
|
|
494
|
+
keepImportAttributes?: boolean;
|
|
495
|
+
/**
|
|
496
|
+
* Use `assert` instead of `with` for imports and exports.
|
|
497
|
+
* This option only works when `keepImportAttributes` is `true`.
|
|
498
|
+
*/
|
|
499
|
+
emitAssertForImportAttributes?: boolean;
|
|
500
|
+
/**
|
|
501
|
+
* Specify the location where SWC stores its intermediate cache files.
|
|
502
|
+
* Currently only transform plugin uses this. If not specified, SWC will
|
|
503
|
+
* create `.swc` directories.
|
|
504
|
+
*/
|
|
505
|
+
cacheRoot?: string;
|
|
506
|
+
/**
|
|
507
|
+
* List of custom transform plugins written in WebAssembly.
|
|
508
|
+
* First parameter of tuple indicates the name of the plugin - it can be either
|
|
509
|
+
* a name of the npm package can be resolved, or absolute path to .wasm binary.
|
|
510
|
+
*
|
|
511
|
+
* Second parameter of tuple is JSON based configuration for the plugin.
|
|
512
|
+
*/
|
|
513
|
+
plugins?: Array<[string, Record<string, any>]>;
|
|
514
|
+
/**
|
|
515
|
+
* Disable builtin transforms. If enabled, only Wasm plugins are used.
|
|
516
|
+
*/
|
|
517
|
+
disableBuiltinTransformsForInternalTesting?: boolean;
|
|
518
|
+
/**
|
|
519
|
+
* Emit isolated dts files for each module.
|
|
520
|
+
*/
|
|
521
|
+
emitIsolatedDts?: boolean;
|
|
522
|
+
};
|
|
523
|
+
baseUrl?: string;
|
|
524
|
+
paths?: {
|
|
525
|
+
[from: string]: string[];
|
|
526
|
+
};
|
|
527
|
+
minify?: JsMinifyOptions;
|
|
528
|
+
preserveAllComments?: boolean;
|
|
529
|
+
}
|
|
530
|
+
export type JscTarget = "es3" | "es5" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "esnext";
|
|
531
|
+
export type ParserConfig = TsParserConfig | EsParserConfig;
|
|
532
|
+
export interface TsParserConfig {
|
|
533
|
+
syntax: "typescript";
|
|
534
|
+
/**
|
|
535
|
+
* Defaults to `false`.
|
|
536
|
+
*/
|
|
537
|
+
tsx?: boolean;
|
|
538
|
+
/**
|
|
539
|
+
* Defaults to `false`.
|
|
540
|
+
*/
|
|
541
|
+
decorators?: boolean;
|
|
542
|
+
/**
|
|
543
|
+
* @deprecated Always true because it's in ecmascript spec.
|
|
544
|
+
*/
|
|
545
|
+
dynamicImport?: boolean;
|
|
546
|
+
}
|
|
547
|
+
export interface EsParserConfig {
|
|
548
|
+
syntax: "ecmascript";
|
|
549
|
+
/**
|
|
550
|
+
* Defaults to false.
|
|
551
|
+
*/
|
|
552
|
+
jsx?: boolean;
|
|
553
|
+
/**
|
|
554
|
+
* @deprecated Always true because it's in ecmascript spec.
|
|
555
|
+
*/
|
|
556
|
+
numericSeparator?: boolean;
|
|
557
|
+
/**
|
|
558
|
+
* @deprecated Always true because it's in ecmascript spec.
|
|
559
|
+
*/
|
|
560
|
+
classPrivateProperty?: boolean;
|
|
561
|
+
/**
|
|
562
|
+
* @deprecated Always true because it's in ecmascript spec.
|
|
563
|
+
*/
|
|
564
|
+
privateMethod?: boolean;
|
|
565
|
+
/**
|
|
566
|
+
* @deprecated Always true because it's in ecmascript spec.
|
|
567
|
+
*/
|
|
568
|
+
classProperty?: boolean;
|
|
569
|
+
/**
|
|
570
|
+
* Defaults to `false`
|
|
571
|
+
*/
|
|
572
|
+
functionBind?: boolean;
|
|
573
|
+
/**
|
|
574
|
+
* Defaults to `false`
|
|
575
|
+
*/
|
|
576
|
+
decorators?: boolean;
|
|
577
|
+
/**
|
|
578
|
+
* Defaults to `false`
|
|
579
|
+
*/
|
|
580
|
+
decoratorsBeforeExport?: boolean;
|
|
581
|
+
/**
|
|
582
|
+
* Defaults to `false`
|
|
583
|
+
*/
|
|
584
|
+
exportDefaultFrom?: boolean;
|
|
585
|
+
/**
|
|
586
|
+
* @deprecated Always true because it's in ecmascript spec.
|
|
587
|
+
*/
|
|
588
|
+
exportNamespaceFrom?: boolean;
|
|
589
|
+
/**
|
|
590
|
+
* @deprecated Always true because it's in ecmascript spec.
|
|
591
|
+
*/
|
|
592
|
+
dynamicImport?: boolean;
|
|
593
|
+
/**
|
|
594
|
+
* @deprecated Always true because it's in ecmascript spec.
|
|
595
|
+
*/
|
|
596
|
+
nullishCoalescing?: boolean;
|
|
597
|
+
/**
|
|
598
|
+
* @deprecated Always true because it's in ecmascript spec.
|
|
599
|
+
*/
|
|
600
|
+
optionalChaining?: boolean;
|
|
601
|
+
/**
|
|
602
|
+
* @deprecated Always true because it's in ecmascript spec.
|
|
603
|
+
*/
|
|
604
|
+
importMeta?: boolean;
|
|
605
|
+
/**
|
|
606
|
+
* @deprecated Always true because it's in ecmascript spec.
|
|
607
|
+
*/
|
|
608
|
+
topLevelAwait?: boolean;
|
|
609
|
+
/**
|
|
610
|
+
* @deprecated An alias of `importAttributes`
|
|
611
|
+
*/
|
|
612
|
+
importAssertions?: boolean;
|
|
613
|
+
/**
|
|
614
|
+
* Defaults to `false`
|
|
615
|
+
*/
|
|
616
|
+
importAttributes?: boolean;
|
|
617
|
+
/**
|
|
618
|
+
* Defaults to `false`
|
|
619
|
+
*/
|
|
620
|
+
allowSuperOutsideMethod?: boolean;
|
|
621
|
+
/**
|
|
622
|
+
* Defaults to `false`
|
|
623
|
+
*/
|
|
624
|
+
allowReturnOutsideFunction?: boolean;
|
|
625
|
+
/**
|
|
626
|
+
* Defaults to `false`
|
|
627
|
+
*/
|
|
628
|
+
autoAccessors?: boolean;
|
|
629
|
+
/**
|
|
630
|
+
* Defaults to `false`
|
|
631
|
+
*/
|
|
632
|
+
explicitResourceManagement?: boolean;
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* Options for transform.
|
|
636
|
+
*/
|
|
637
|
+
export interface TransformConfig {
|
|
638
|
+
/**
|
|
639
|
+
* Effective only if `syntax` supports ƒ.
|
|
640
|
+
*/
|
|
641
|
+
react?: ReactConfig;
|
|
642
|
+
constModules?: ConstModulesConfig;
|
|
643
|
+
/**
|
|
644
|
+
* Defaults to null, which skips optimizer pass.
|
|
645
|
+
*/
|
|
646
|
+
optimizer?: OptimizerConfig;
|
|
647
|
+
/**
|
|
648
|
+
* https://swc.rs/docs/configuring-swc.html#jsctransformlegacydecorator
|
|
649
|
+
*/
|
|
650
|
+
legacyDecorator?: boolean;
|
|
651
|
+
/**
|
|
652
|
+
* https://swc.rs/docs/configuring-swc.html#jsctransformdecoratormetadata
|
|
653
|
+
*/
|
|
654
|
+
decoratorMetadata?: boolean;
|
|
655
|
+
/**
|
|
656
|
+
* https://swc.rs/docs/configuration/compilation#jsctransformdecoratorversion
|
|
657
|
+
*/
|
|
658
|
+
decoratorVersion?: "2021-12" | "2022-03";
|
|
659
|
+
treatConstEnumAsEnum?: boolean;
|
|
660
|
+
useDefineForClassFields?: boolean;
|
|
661
|
+
}
|
|
662
|
+
export interface ReactConfig {
|
|
663
|
+
/**
|
|
664
|
+
* Replace the function used when compiling JSX expressions.
|
|
665
|
+
*
|
|
666
|
+
* Defaults to `React.createElement`.
|
|
667
|
+
*/
|
|
668
|
+
pragma?: string;
|
|
669
|
+
/**
|
|
670
|
+
* Replace the component used when compiling JSX fragments.
|
|
671
|
+
*
|
|
672
|
+
* Defaults to `React.Fragment`
|
|
673
|
+
*/
|
|
674
|
+
pragmaFrag?: string;
|
|
675
|
+
/**
|
|
676
|
+
* Toggles whether or not to throw an error if a XML namespaced tag name is used. For example:
|
|
677
|
+
* `<f:image />`
|
|
678
|
+
*
|
|
679
|
+
* Though the JSX spec allows this, it is disabled by default since React's
|
|
680
|
+
* JSX does not currently have support for it.
|
|
681
|
+
*
|
|
682
|
+
*/
|
|
683
|
+
throwIfNamespace?: boolean;
|
|
684
|
+
/**
|
|
685
|
+
* Toggles plugins that aid in development, such as @swc/plugin-transform-react-jsx-self
|
|
686
|
+
* and @swc/plugin-transform-react-jsx-source.
|
|
687
|
+
*
|
|
688
|
+
* Defaults to `false`,
|
|
689
|
+
*
|
|
690
|
+
*/
|
|
691
|
+
development?: boolean;
|
|
692
|
+
/**
|
|
693
|
+
* Use `Object.assign()` instead of `_extends`. Defaults to false.
|
|
694
|
+
* @deprecated
|
|
695
|
+
*/
|
|
696
|
+
useBuiltins?: boolean;
|
|
697
|
+
/**
|
|
698
|
+
* Enable fast refresh feature for React app
|
|
699
|
+
*/
|
|
700
|
+
refresh?: boolean;
|
|
701
|
+
/**
|
|
702
|
+
* jsx runtime
|
|
703
|
+
*/
|
|
704
|
+
runtime?: "automatic" | "classic";
|
|
705
|
+
/**
|
|
706
|
+
* Declares the module specifier to be used for importing the `jsx` and `jsxs` factory functions when using `runtime` 'automatic'
|
|
707
|
+
*/
|
|
708
|
+
importSource?: string;
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* - `import { DEBUG } from '@ember/env-flags';`
|
|
712
|
+
* - `import { FEATURE_A, FEATURE_B } from '@ember/features';`
|
|
713
|
+
*
|
|
714
|
+
* See: https://github.com/swc-project/swc/issues/18#issuecomment-466272558
|
|
715
|
+
*/
|
|
716
|
+
export interface ConstModulesConfig {
|
|
717
|
+
globals?: {
|
|
718
|
+
[module: string]: {
|
|
719
|
+
[name: string]: string;
|
|
720
|
+
};
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
export interface OptimizerConfig {
|
|
724
|
+
simplify?: boolean;
|
|
725
|
+
globals?: GlobalPassOption;
|
|
726
|
+
jsonify?: {
|
|
727
|
+
minCost: number;
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* Options for inline-global pass.
|
|
732
|
+
*/
|
|
733
|
+
export interface GlobalPassOption {
|
|
734
|
+
/**
|
|
735
|
+
* Global variables that should be inlined with passed value.
|
|
736
|
+
*
|
|
737
|
+
* e.g. `{ __DEBUG__: true }`
|
|
738
|
+
*/
|
|
739
|
+
vars?: Record<string, string>;
|
|
740
|
+
/**
|
|
741
|
+
* Names of environment variables that should be inlined with the value of corresponding env during build.
|
|
742
|
+
*
|
|
743
|
+
* Defaults to `["NODE_ENV", "SWC_ENV"]`
|
|
744
|
+
*/
|
|
745
|
+
envs?: string[] | Record<string, string>;
|
|
746
|
+
/**
|
|
747
|
+
* Replaces typeof calls for passed variables with corresponding value
|
|
748
|
+
*
|
|
749
|
+
* e.g. `{ window: 'object' }`
|
|
750
|
+
*/
|
|
751
|
+
typeofs?: Record<string, string>;
|
|
752
|
+
}
|
|
753
|
+
export type ModuleConfig = Es6Config | CommonJsConfig | UmdConfig | AmdConfig | NodeNextConfig | SystemjsConfig;
|
|
754
|
+
export interface BaseModuleConfig {
|
|
755
|
+
/**
|
|
756
|
+
* By default, when using exports with babel a non-enumerable `__esModule`
|
|
757
|
+
* property is exported. In some cases this property is used to determine
|
|
758
|
+
* if the import is the default export or if it contains the default export.
|
|
759
|
+
*
|
|
760
|
+
* In order to prevent the __esModule property from being exported, you
|
|
761
|
+
* can set the strict option to true.
|
|
762
|
+
*
|
|
763
|
+
* Defaults to `false`.
|
|
764
|
+
*/
|
|
765
|
+
strict?: boolean;
|
|
766
|
+
/**
|
|
767
|
+
* Emits 'use strict' directive.
|
|
768
|
+
*
|
|
769
|
+
* Defaults to `true`.
|
|
770
|
+
*/
|
|
771
|
+
strictMode?: boolean;
|
|
772
|
+
/**
|
|
773
|
+
* Changes Babel's compiled import statements to be lazily evaluated when their imported bindings are used for the first time.
|
|
774
|
+
*
|
|
775
|
+
* This can improve initial load time of your module because evaluating dependencies up
|
|
776
|
+
* front is sometimes entirely un-necessary. This is especially the case when implementing
|
|
777
|
+
* a library module.
|
|
778
|
+
*
|
|
779
|
+
*
|
|
780
|
+
* The value of `lazy` has a few possible effects:
|
|
781
|
+
*
|
|
782
|
+
* - `false` - No lazy initialization of any imported module.
|
|
783
|
+
* - `true` - Do not lazy-initialize local `./foo` imports, but lazy-init `foo` dependencies.
|
|
784
|
+
*
|
|
785
|
+
* Local paths are much more likely to have circular dependencies, which may break if loaded lazily,
|
|
786
|
+
* so they are not lazy by default, whereas dependencies between independent modules are rarely cyclical.
|
|
787
|
+
*
|
|
788
|
+
* - `Array<string>` - Lazy-initialize all imports with source matching one of the given strings.
|
|
789
|
+
*
|
|
790
|
+
* -----
|
|
791
|
+
*
|
|
792
|
+
* The two cases where imports can never be lazy are:
|
|
793
|
+
*
|
|
794
|
+
* - `import "foo";`
|
|
795
|
+
*
|
|
796
|
+
* Side-effect imports are automatically non-lazy since their very existence means
|
|
797
|
+
* that there is no binding to later kick off initialization.
|
|
798
|
+
*
|
|
799
|
+
* - `export * from "foo"`
|
|
800
|
+
*
|
|
801
|
+
* Re-exporting all names requires up-front execution because otherwise there is no
|
|
802
|
+
* way to know what names need to be exported.
|
|
803
|
+
*
|
|
804
|
+
* Defaults to `false`.
|
|
805
|
+
*/
|
|
806
|
+
lazy?: boolean | string[];
|
|
807
|
+
/**
|
|
808
|
+
* @deprecated Use the `importInterop` option instead.
|
|
809
|
+
*
|
|
810
|
+
* By default, when using exports with swc a non-enumerable __esModule property is exported.
|
|
811
|
+
* This property is then used to determine if the import is the default export or if
|
|
812
|
+
* it contains the default export.
|
|
813
|
+
*
|
|
814
|
+
* In cases where the auto-unwrapping of default is not needed, you can set the noInterop option
|
|
815
|
+
* to true to avoid the usage of the interopRequireDefault helper (shown in inline form above).
|
|
816
|
+
*
|
|
817
|
+
* Defaults to `false`.
|
|
818
|
+
*/
|
|
819
|
+
noInterop?: boolean;
|
|
820
|
+
/**
|
|
821
|
+
* Defaults to `swc`.
|
|
822
|
+
*
|
|
823
|
+
* CommonJS modules and ECMAScript modules are not fully compatible.
|
|
824
|
+
* However, compilers, bundlers and JavaScript runtimes developed different strategies
|
|
825
|
+
* to make them work together as well as possible.
|
|
826
|
+
*
|
|
827
|
+
* - `swc` (alias: `babel`)
|
|
828
|
+
*
|
|
829
|
+
* When using exports with `swc` a non-enumerable `__esModule` property is exported
|
|
830
|
+
* This property is then used to determine if the import is the default export
|
|
831
|
+
* or if it contains the default export.
|
|
832
|
+
*
|
|
833
|
+
* ```javascript
|
|
834
|
+
* import foo from "foo";
|
|
835
|
+
* import { bar } from "bar";
|
|
836
|
+
* foo;
|
|
837
|
+
* bar;
|
|
838
|
+
*
|
|
839
|
+
* // Is compiled to ...
|
|
840
|
+
*
|
|
841
|
+
* "use strict";
|
|
842
|
+
*
|
|
843
|
+
* function _interop_require_default(obj) {
|
|
844
|
+
* return obj && obj.__esModule ? obj : { default: obj };
|
|
845
|
+
* }
|
|
846
|
+
*
|
|
847
|
+
* var _foo = _interop_require_default(require("foo"));
|
|
848
|
+
* var _bar = require("bar");
|
|
849
|
+
*
|
|
850
|
+
* _foo.default;
|
|
851
|
+
* _bar.bar;
|
|
852
|
+
* ```
|
|
853
|
+
*
|
|
854
|
+
* When this import interop is used, if both the imported and the importer module are compiled
|
|
855
|
+
* with swc they behave as if none of them was compiled.
|
|
856
|
+
*
|
|
857
|
+
* This is the default behavior.
|
|
858
|
+
*
|
|
859
|
+
* - `node`
|
|
860
|
+
*
|
|
861
|
+
* When importing CommonJS files (either directly written in CommonJS, or generated with a compiler)
|
|
862
|
+
* Node.js always binds the `default` export to the value of `module.exports`.
|
|
863
|
+
*
|
|
864
|
+
* ```javascript
|
|
865
|
+
* import foo from "foo";
|
|
866
|
+
* import { bar } from "bar";
|
|
867
|
+
* foo;
|
|
868
|
+
* bar;
|
|
869
|
+
*
|
|
870
|
+
* // Is compiled to ...
|
|
871
|
+
*
|
|
872
|
+
* "use strict";
|
|
873
|
+
*
|
|
874
|
+
* var _foo = require("foo");
|
|
875
|
+
* var _bar = require("bar");
|
|
876
|
+
*
|
|
877
|
+
* _foo;
|
|
878
|
+
* _bar.bar;
|
|
879
|
+
* ```
|
|
880
|
+
* This is not exactly the same as what Node.js does since swc allows accessing any property of `module.exports`
|
|
881
|
+
* as a named export, while Node.js only allows importing statically analyzable properties of `module.exports`.
|
|
882
|
+
* However, any import working in Node.js will also work when compiled with swc using `importInterop: "node"`.
|
|
883
|
+
*
|
|
884
|
+
* - `none`
|
|
885
|
+
*
|
|
886
|
+
* If you know that the imported file has been transformed with a compiler that stores the `default` export on
|
|
887
|
+
* `exports.default` (such as swc or Babel), you can safely omit the `_interop_require_default` helper.
|
|
888
|
+
*
|
|
889
|
+
* ```javascript
|
|
890
|
+
* import foo from "foo";
|
|
891
|
+
* import { bar } from "bar";
|
|
892
|
+
* foo;
|
|
893
|
+
* bar;
|
|
894
|
+
*
|
|
895
|
+
* // Is compiled to ...
|
|
896
|
+
*
|
|
897
|
+
* "use strict";
|
|
898
|
+
*
|
|
899
|
+
* var _foo = require("foo");
|
|
900
|
+
* var _bar = require("bar");
|
|
901
|
+
*
|
|
902
|
+
* _foo.default;
|
|
903
|
+
* _bar.bar;
|
|
904
|
+
* ```
|
|
905
|
+
*/
|
|
906
|
+
importInterop?: "swc" | "babel" | "node" | "none";
|
|
907
|
+
/**
|
|
908
|
+
* Emits `cjs-module-lexer` annotation
|
|
909
|
+
* `cjs-module-lexer` is used in Node.js core for detecting the named exports available when importing a CJS module into ESM.
|
|
910
|
+
* swc will emit `cjs-module-lexer` detectable annotation with this option enabled.
|
|
911
|
+
*
|
|
912
|
+
* Defaults to `true` if import_interop is Node, else `false`
|
|
913
|
+
*/
|
|
914
|
+
exportInteropAnnotation?: boolean;
|
|
915
|
+
/**
|
|
916
|
+
* If set to true, dynamic imports will be preserved.
|
|
917
|
+
*/
|
|
918
|
+
ignoreDynamic?: boolean;
|
|
919
|
+
allowTopLevelThis?: boolean;
|
|
920
|
+
preserveImportMeta?: boolean;
|
|
921
|
+
}
|
|
922
|
+
export interface Es6Config extends BaseModuleConfig {
|
|
923
|
+
type: "es6";
|
|
924
|
+
}
|
|
925
|
+
export interface NodeNextConfig extends BaseModuleConfig {
|
|
926
|
+
type: "nodenext";
|
|
927
|
+
}
|
|
928
|
+
export interface CommonJsConfig extends BaseModuleConfig {
|
|
929
|
+
type: "commonjs";
|
|
930
|
+
}
|
|
931
|
+
export interface UmdConfig extends BaseModuleConfig {
|
|
932
|
+
type: "umd";
|
|
933
|
+
globals?: {
|
|
934
|
+
[key: string]: string;
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
export interface AmdConfig extends BaseModuleConfig {
|
|
938
|
+
type: "amd";
|
|
939
|
+
moduleId?: string;
|
|
940
|
+
}
|
|
941
|
+
export interface SystemjsConfig {
|
|
942
|
+
type: "systemjs";
|
|
943
|
+
allowTopLevelThis?: boolean;
|
|
944
|
+
}
|
|
945
|
+
export interface Output {
|
|
946
|
+
/**
|
|
947
|
+
* Transformed code
|
|
948
|
+
*/
|
|
949
|
+
code: string;
|
|
950
|
+
/**
|
|
951
|
+
* Sourcemap (**not** base64 encoded)
|
|
952
|
+
*/
|
|
953
|
+
map?: string;
|
|
954
|
+
}
|
|
955
|
+
export interface MatchPattern {
|
|
956
|
+
}
|
|
957
|
+
export interface Span {
|
|
958
|
+
start: number;
|
|
959
|
+
end: number;
|
|
960
|
+
ctxt: number;
|
|
961
|
+
}
|
|
962
|
+
export interface Node {
|
|
963
|
+
type: string;
|
|
964
|
+
}
|
|
965
|
+
export interface HasSpan {
|
|
966
|
+
span: Span;
|
|
967
|
+
}
|
|
968
|
+
export interface HasDecorator {
|
|
969
|
+
decorators?: Decorator[];
|
|
970
|
+
}
|
|
971
|
+
export interface Class extends HasSpan, HasDecorator {
|
|
972
|
+
body: ClassMember[];
|
|
973
|
+
superClass?: Expression;
|
|
974
|
+
isAbstract: boolean;
|
|
975
|
+
typeParams?: TsTypeParameterDeclaration;
|
|
976
|
+
superTypeParams?: TsTypeParameterInstantiation;
|
|
977
|
+
implements: TsExpressionWithTypeArguments[];
|
|
978
|
+
}
|
|
979
|
+
export type ClassMember = Constructor | ClassMethod | PrivateMethod | ClassProperty | PrivateProperty | TsIndexSignature | EmptyStatement | StaticBlock;
|
|
980
|
+
export interface ClassPropertyBase extends Node, HasSpan, HasDecorator {
|
|
981
|
+
value?: Expression;
|
|
982
|
+
typeAnnotation?: TsTypeAnnotation;
|
|
983
|
+
isStatic: boolean;
|
|
984
|
+
accessibility?: Accessibility;
|
|
985
|
+
isOptional: boolean;
|
|
986
|
+
isOverride: boolean;
|
|
987
|
+
readonly: boolean;
|
|
988
|
+
definite: boolean;
|
|
989
|
+
}
|
|
990
|
+
export interface ClassProperty extends ClassPropertyBase {
|
|
991
|
+
type: "ClassProperty";
|
|
992
|
+
key: PropertyName;
|
|
993
|
+
isAbstract: boolean;
|
|
994
|
+
declare: boolean;
|
|
995
|
+
}
|
|
996
|
+
export interface PrivateProperty extends ClassPropertyBase {
|
|
997
|
+
type: "PrivateProperty";
|
|
998
|
+
key: PrivateName;
|
|
999
|
+
}
|
|
1000
|
+
export interface Param extends Node, HasSpan, HasDecorator {
|
|
1001
|
+
type: "Parameter";
|
|
1002
|
+
pat: Pattern;
|
|
1003
|
+
}
|
|
1004
|
+
export interface Constructor extends Node, HasSpan {
|
|
1005
|
+
type: "Constructor";
|
|
1006
|
+
key: PropertyName;
|
|
1007
|
+
params: (TsParameterProperty | Param)[];
|
|
1008
|
+
body?: BlockStatement;
|
|
1009
|
+
accessibility?: Accessibility;
|
|
1010
|
+
isOptional: boolean;
|
|
1011
|
+
}
|
|
1012
|
+
export interface ClassMethodBase extends Node, HasSpan {
|
|
1013
|
+
function: Fn;
|
|
1014
|
+
kind: MethodKind;
|
|
1015
|
+
isStatic: boolean;
|
|
1016
|
+
accessibility?: Accessibility;
|
|
1017
|
+
isAbstract: boolean;
|
|
1018
|
+
isOptional: boolean;
|
|
1019
|
+
isOverride: boolean;
|
|
1020
|
+
}
|
|
1021
|
+
export interface ClassMethod extends ClassMethodBase {
|
|
1022
|
+
type: "ClassMethod";
|
|
1023
|
+
key: PropertyName;
|
|
1024
|
+
}
|
|
1025
|
+
export interface PrivateMethod extends ClassMethodBase {
|
|
1026
|
+
type: "PrivateMethod";
|
|
1027
|
+
key: PrivateName;
|
|
1028
|
+
}
|
|
1029
|
+
export interface StaticBlock extends Node, HasSpan {
|
|
1030
|
+
type: "StaticBlock";
|
|
1031
|
+
body: BlockStatement;
|
|
1032
|
+
}
|
|
1033
|
+
export interface Decorator extends Node, HasSpan {
|
|
1034
|
+
type: "Decorator";
|
|
1035
|
+
expression: Expression;
|
|
1036
|
+
}
|
|
1037
|
+
export type MethodKind = "method" | "getter" | "setter";
|
|
1038
|
+
export type Declaration = ClassDeclaration | FunctionDeclaration | VariableDeclaration | TsInterfaceDeclaration | TsTypeAliasDeclaration | TsEnumDeclaration | TsModuleDeclaration;
|
|
1039
|
+
export interface FunctionDeclaration extends Fn {
|
|
1040
|
+
type: "FunctionDeclaration";
|
|
1041
|
+
identifier: Identifier;
|
|
1042
|
+
declare: boolean;
|
|
1043
|
+
}
|
|
1044
|
+
export interface ClassDeclaration extends Class, Node {
|
|
1045
|
+
type: "ClassDeclaration";
|
|
1046
|
+
identifier: Identifier;
|
|
1047
|
+
declare: boolean;
|
|
1048
|
+
}
|
|
1049
|
+
export interface VariableDeclaration extends Node, HasSpan {
|
|
1050
|
+
type: "VariableDeclaration";
|
|
1051
|
+
kind: VariableDeclarationKind;
|
|
1052
|
+
declare: boolean;
|
|
1053
|
+
declarations: VariableDeclarator[];
|
|
1054
|
+
}
|
|
1055
|
+
export type VariableDeclarationKind = "var" | "let" | "const";
|
|
1056
|
+
export interface VariableDeclarator extends Node, HasSpan {
|
|
1057
|
+
type: "VariableDeclarator";
|
|
1058
|
+
id: Pattern;
|
|
1059
|
+
init?: Expression;
|
|
1060
|
+
definite: boolean;
|
|
1061
|
+
}
|
|
1062
|
+
export 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;
|
|
1063
|
+
interface ExpressionBase extends Node, HasSpan {
|
|
1064
|
+
}
|
|
1065
|
+
export interface Identifier extends ExpressionBase {
|
|
1066
|
+
type: "Identifier";
|
|
1067
|
+
value: string;
|
|
1068
|
+
optional: boolean;
|
|
1069
|
+
}
|
|
1070
|
+
export interface OptionalChainingExpression extends ExpressionBase {
|
|
1071
|
+
type: "OptionalChainingExpression";
|
|
1072
|
+
questionDotToken: Span;
|
|
1073
|
+
/**
|
|
1074
|
+
* Call expression or member expression.
|
|
1075
|
+
*/
|
|
1076
|
+
base: MemberExpression | OptionalChainingCall;
|
|
1077
|
+
}
|
|
1078
|
+
export interface OptionalChainingCall extends ExpressionBase {
|
|
1079
|
+
type: "CallExpression";
|
|
1080
|
+
callee: Expression;
|
|
1081
|
+
arguments: ExprOrSpread[];
|
|
1082
|
+
typeArguments?: TsTypeParameterInstantiation;
|
|
1083
|
+
}
|
|
1084
|
+
export interface ThisExpression extends ExpressionBase {
|
|
1085
|
+
type: "ThisExpression";
|
|
1086
|
+
}
|
|
1087
|
+
export interface ArrayExpression extends ExpressionBase {
|
|
1088
|
+
type: "ArrayExpression";
|
|
1089
|
+
elements: (ExprOrSpread | undefined)[];
|
|
1090
|
+
}
|
|
1091
|
+
export interface ExprOrSpread {
|
|
1092
|
+
spread?: Span;
|
|
1093
|
+
expression: Expression;
|
|
1094
|
+
}
|
|
1095
|
+
export interface ObjectExpression extends ExpressionBase {
|
|
1096
|
+
type: "ObjectExpression";
|
|
1097
|
+
properties: (SpreadElement | Property)[];
|
|
1098
|
+
}
|
|
1099
|
+
export interface Argument {
|
|
1100
|
+
spread?: Span;
|
|
1101
|
+
expression: Expression;
|
|
1102
|
+
}
|
|
1103
|
+
export interface SpreadElement extends Node {
|
|
1104
|
+
type: "SpreadElement";
|
|
1105
|
+
spread: Span;
|
|
1106
|
+
arguments: Expression;
|
|
1107
|
+
}
|
|
1108
|
+
export interface UnaryExpression extends ExpressionBase {
|
|
1109
|
+
type: "UnaryExpression";
|
|
1110
|
+
operator: UnaryOperator;
|
|
1111
|
+
argument: Expression;
|
|
1112
|
+
}
|
|
1113
|
+
export interface UpdateExpression extends ExpressionBase {
|
|
1114
|
+
type: "UpdateExpression";
|
|
1115
|
+
operator: UpdateOperator;
|
|
1116
|
+
prefix: boolean;
|
|
1117
|
+
argument: Expression;
|
|
1118
|
+
}
|
|
1119
|
+
export interface BinaryExpression extends ExpressionBase {
|
|
1120
|
+
type: "BinaryExpression";
|
|
1121
|
+
operator: BinaryOperator;
|
|
1122
|
+
left: Expression;
|
|
1123
|
+
right: Expression;
|
|
1124
|
+
}
|
|
1125
|
+
export interface FunctionExpression extends Fn, ExpressionBase {
|
|
1126
|
+
type: "FunctionExpression";
|
|
1127
|
+
identifier?: Identifier;
|
|
1128
|
+
}
|
|
1129
|
+
export interface ClassExpression extends Class, ExpressionBase {
|
|
1130
|
+
type: "ClassExpression";
|
|
1131
|
+
identifier?: Identifier;
|
|
1132
|
+
}
|
|
1133
|
+
export interface AssignmentExpression extends ExpressionBase {
|
|
1134
|
+
type: "AssignmentExpression";
|
|
1135
|
+
operator: AssignmentOperator;
|
|
1136
|
+
left: Expression | Pattern;
|
|
1137
|
+
right: Expression;
|
|
1138
|
+
}
|
|
1139
|
+
export interface MemberExpression extends ExpressionBase {
|
|
1140
|
+
type: "MemberExpression";
|
|
1141
|
+
object: Expression;
|
|
1142
|
+
property: Identifier | PrivateName | ComputedPropName;
|
|
1143
|
+
}
|
|
1144
|
+
export interface SuperPropExpression extends ExpressionBase {
|
|
1145
|
+
type: "SuperPropExpression";
|
|
1146
|
+
obj: Super;
|
|
1147
|
+
property: Identifier | ComputedPropName;
|
|
1148
|
+
}
|
|
1149
|
+
export interface ConditionalExpression extends ExpressionBase {
|
|
1150
|
+
type: "ConditionalExpression";
|
|
1151
|
+
test: Expression;
|
|
1152
|
+
consequent: Expression;
|
|
1153
|
+
alternate: Expression;
|
|
1154
|
+
}
|
|
1155
|
+
export interface Super extends Node, HasSpan {
|
|
1156
|
+
type: "Super";
|
|
1157
|
+
}
|
|
1158
|
+
export interface Import extends Node, HasSpan {
|
|
1159
|
+
type: "Import";
|
|
1160
|
+
}
|
|
1161
|
+
export interface CallExpression extends ExpressionBase {
|
|
1162
|
+
type: "CallExpression";
|
|
1163
|
+
callee: Super | Import | Expression;
|
|
1164
|
+
arguments: Argument[];
|
|
1165
|
+
typeArguments?: TsTypeParameterInstantiation;
|
|
1166
|
+
}
|
|
1167
|
+
export interface NewExpression extends ExpressionBase {
|
|
1168
|
+
type: "NewExpression";
|
|
1169
|
+
callee: Expression;
|
|
1170
|
+
arguments?: Argument[];
|
|
1171
|
+
typeArguments?: TsTypeParameterInstantiation;
|
|
1172
|
+
}
|
|
1173
|
+
export interface SequenceExpression extends ExpressionBase {
|
|
1174
|
+
type: "SequenceExpression";
|
|
1175
|
+
expressions: Expression[];
|
|
1176
|
+
}
|
|
1177
|
+
export interface ArrowFunctionExpression extends ExpressionBase {
|
|
1178
|
+
type: "ArrowFunctionExpression";
|
|
1179
|
+
params: Pattern[];
|
|
1180
|
+
body: BlockStatement | Expression;
|
|
1181
|
+
async: boolean;
|
|
1182
|
+
generator: boolean;
|
|
1183
|
+
typeParameters?: TsTypeParameterDeclaration;
|
|
1184
|
+
returnType?: TsTypeAnnotation;
|
|
1185
|
+
}
|
|
1186
|
+
export interface YieldExpression extends ExpressionBase {
|
|
1187
|
+
type: "YieldExpression";
|
|
1188
|
+
argument?: Expression;
|
|
1189
|
+
delegate: boolean;
|
|
1190
|
+
}
|
|
1191
|
+
export interface MetaProperty extends Node, HasSpan {
|
|
1192
|
+
type: "MetaProperty";
|
|
1193
|
+
kind: "new.target" | "import.meta";
|
|
1194
|
+
}
|
|
1195
|
+
export interface AwaitExpression extends ExpressionBase {
|
|
1196
|
+
type: "AwaitExpression";
|
|
1197
|
+
argument: Expression;
|
|
1198
|
+
}
|
|
1199
|
+
export interface TemplateLiteral extends ExpressionBase {
|
|
1200
|
+
type: "TemplateLiteral";
|
|
1201
|
+
expressions: Expression[];
|
|
1202
|
+
quasis: TemplateElement[];
|
|
1203
|
+
}
|
|
1204
|
+
export interface TaggedTemplateExpression extends ExpressionBase {
|
|
1205
|
+
type: "TaggedTemplateExpression";
|
|
1206
|
+
tag: Expression;
|
|
1207
|
+
typeParameters?: TsTypeParameterInstantiation;
|
|
1208
|
+
template: TemplateLiteral;
|
|
1209
|
+
}
|
|
1210
|
+
export interface TemplateElement extends ExpressionBase {
|
|
1211
|
+
type: "TemplateElement";
|
|
1212
|
+
tail: boolean;
|
|
1213
|
+
cooked?: string;
|
|
1214
|
+
raw: string;
|
|
1215
|
+
}
|
|
1216
|
+
export interface ParenthesisExpression extends ExpressionBase {
|
|
1217
|
+
type: "ParenthesisExpression";
|
|
1218
|
+
expression: Expression;
|
|
1219
|
+
}
|
|
1220
|
+
export interface Fn extends HasSpan, HasDecorator {
|
|
1221
|
+
params: Param[];
|
|
1222
|
+
body?: BlockStatement;
|
|
1223
|
+
generator: boolean;
|
|
1224
|
+
async: boolean;
|
|
1225
|
+
typeParameters?: TsTypeParameterDeclaration;
|
|
1226
|
+
returnType?: TsTypeAnnotation;
|
|
1227
|
+
}
|
|
1228
|
+
interface PatternBase extends Node, HasSpan {
|
|
1229
|
+
typeAnnotation?: TsTypeAnnotation;
|
|
1230
|
+
}
|
|
1231
|
+
export interface PrivateName extends ExpressionBase {
|
|
1232
|
+
type: "PrivateName";
|
|
1233
|
+
id: Identifier;
|
|
1234
|
+
}
|
|
1235
|
+
export type JSXObject = JSXMemberExpression | Identifier;
|
|
1236
|
+
export interface JSXMemberExpression extends Node {
|
|
1237
|
+
type: "JSXMemberExpression";
|
|
1238
|
+
object: JSXObject;
|
|
1239
|
+
property: Identifier;
|
|
1240
|
+
}
|
|
1241
|
+
/**
|
|
1242
|
+
* XML-based namespace syntax:
|
|
1243
|
+
*/
|
|
1244
|
+
export interface JSXNamespacedName extends Node {
|
|
1245
|
+
type: "JSXNamespacedName";
|
|
1246
|
+
namespace: Identifier;
|
|
1247
|
+
name: Identifier;
|
|
1248
|
+
}
|
|
1249
|
+
export interface JSXEmptyExpression extends Node, HasSpan {
|
|
1250
|
+
type: "JSXEmptyExpression";
|
|
1251
|
+
}
|
|
1252
|
+
export interface JSXExpressionContainer extends Node, HasSpan {
|
|
1253
|
+
type: "JSXExpressionContainer";
|
|
1254
|
+
expression: JSXExpression;
|
|
1255
|
+
}
|
|
1256
|
+
export type JSXExpression = JSXEmptyExpression | Expression;
|
|
1257
|
+
export interface JSXSpreadChild extends Node, HasSpan {
|
|
1258
|
+
type: "JSXSpreadChild";
|
|
1259
|
+
expression: Expression;
|
|
1260
|
+
}
|
|
1261
|
+
export type JSXElementName = Identifier | JSXMemberExpression | JSXNamespacedName;
|
|
1262
|
+
export interface JSXOpeningElement extends Node, HasSpan {
|
|
1263
|
+
type: "JSXOpeningElement";
|
|
1264
|
+
name: JSXElementName;
|
|
1265
|
+
attributes: JSXAttributeOrSpread[];
|
|
1266
|
+
selfClosing: boolean;
|
|
1267
|
+
typeArguments?: TsTypeParameterInstantiation;
|
|
1268
|
+
}
|
|
1269
|
+
export type JSXAttributeOrSpread = JSXAttribute | SpreadElement;
|
|
1270
|
+
export interface JSXClosingElement extends Node, HasSpan {
|
|
1271
|
+
type: "JSXClosingElement";
|
|
1272
|
+
name: JSXElementName;
|
|
1273
|
+
}
|
|
1274
|
+
export interface JSXAttribute extends Node, HasSpan {
|
|
1275
|
+
type: "JSXAttribute";
|
|
1276
|
+
name: JSXAttributeName;
|
|
1277
|
+
value?: JSXAttrValue;
|
|
1278
|
+
}
|
|
1279
|
+
export type JSXAttributeName = Identifier | JSXNamespacedName;
|
|
1280
|
+
export type JSXAttrValue = Literal | JSXExpressionContainer | JSXElement | JSXFragment;
|
|
1281
|
+
export interface JSXText extends Node, HasSpan {
|
|
1282
|
+
type: "JSXText";
|
|
1283
|
+
value: string;
|
|
1284
|
+
raw: string;
|
|
1285
|
+
}
|
|
1286
|
+
export interface JSXElement extends Node, HasSpan {
|
|
1287
|
+
type: "JSXElement";
|
|
1288
|
+
opening: JSXOpeningElement;
|
|
1289
|
+
children: JSXElementChild[];
|
|
1290
|
+
closing?: JSXClosingElement;
|
|
1291
|
+
}
|
|
1292
|
+
export type JSXElementChild = JSXText | JSXExpressionContainer | JSXSpreadChild | JSXElement | JSXFragment;
|
|
1293
|
+
export interface JSXFragment extends Node, HasSpan {
|
|
1294
|
+
type: "JSXFragment";
|
|
1295
|
+
opening: JSXOpeningFragment;
|
|
1296
|
+
children: JSXElementChild[];
|
|
1297
|
+
closing: JSXClosingFragment;
|
|
1298
|
+
}
|
|
1299
|
+
export interface JSXOpeningFragment extends Node, HasSpan {
|
|
1300
|
+
type: "JSXOpeningFragment";
|
|
1301
|
+
}
|
|
1302
|
+
export interface JSXClosingFragment extends Node, HasSpan {
|
|
1303
|
+
type: "JSXClosingFragment";
|
|
1304
|
+
}
|
|
1305
|
+
export type Literal = StringLiteral | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | JSXText;
|
|
1306
|
+
export interface StringLiteral extends Node, HasSpan {
|
|
1307
|
+
type: "StringLiteral";
|
|
1308
|
+
value: string;
|
|
1309
|
+
raw?: string;
|
|
1310
|
+
}
|
|
1311
|
+
export interface BooleanLiteral extends Node, HasSpan {
|
|
1312
|
+
type: "BooleanLiteral";
|
|
1313
|
+
value: boolean;
|
|
1314
|
+
}
|
|
1315
|
+
export interface NullLiteral extends Node, HasSpan {
|
|
1316
|
+
type: "NullLiteral";
|
|
1317
|
+
}
|
|
1318
|
+
export interface RegExpLiteral extends Node, HasSpan {
|
|
1319
|
+
type: "RegExpLiteral";
|
|
1320
|
+
pattern: string;
|
|
1321
|
+
flags: string;
|
|
1322
|
+
}
|
|
1323
|
+
export interface NumericLiteral extends Node, HasSpan {
|
|
1324
|
+
type: "NumericLiteral";
|
|
1325
|
+
value: number;
|
|
1326
|
+
raw?: string;
|
|
1327
|
+
}
|
|
1328
|
+
export interface BigIntLiteral extends Node, HasSpan {
|
|
1329
|
+
type: "BigIntLiteral";
|
|
1330
|
+
value: bigint;
|
|
1331
|
+
raw?: string;
|
|
1332
|
+
}
|
|
1333
|
+
export type ModuleDeclaration = ImportDeclaration | ExportDeclaration | ExportNamedDeclaration | ExportDefaultDeclaration | ExportDefaultExpression | ExportAllDeclaration | TsImportEqualsDeclaration | TsExportAssignment | TsNamespaceExportDeclaration;
|
|
1334
|
+
export interface ExportDefaultExpression extends Node, HasSpan {
|
|
1335
|
+
type: "ExportDefaultExpression";
|
|
1336
|
+
expression: Expression;
|
|
1337
|
+
}
|
|
1338
|
+
export interface ExportDeclaration extends Node, HasSpan {
|
|
1339
|
+
type: "ExportDeclaration";
|
|
1340
|
+
declaration: Declaration;
|
|
1341
|
+
}
|
|
1342
|
+
export interface ImportDeclaration extends Node, HasSpan {
|
|
1343
|
+
type: "ImportDeclaration";
|
|
1344
|
+
specifiers: ImportSpecifier[];
|
|
1345
|
+
source: StringLiteral;
|
|
1346
|
+
typeOnly: boolean;
|
|
1347
|
+
asserts?: ObjectExpression;
|
|
1348
|
+
}
|
|
1349
|
+
export interface ExportAllDeclaration extends Node, HasSpan {
|
|
1350
|
+
type: "ExportAllDeclaration";
|
|
1351
|
+
source: StringLiteral;
|
|
1352
|
+
asserts?: ObjectExpression;
|
|
1353
|
+
}
|
|
1354
|
+
/**
|
|
1355
|
+
* - `export { foo } from 'mod'`
|
|
1356
|
+
* - `export { foo as bar } from 'mod'`
|
|
1357
|
+
*/
|
|
1358
|
+
export interface ExportNamedDeclaration extends Node, HasSpan {
|
|
1359
|
+
type: "ExportNamedDeclaration";
|
|
1360
|
+
specifiers: ExportSpecifier[];
|
|
1361
|
+
source?: StringLiteral;
|
|
1362
|
+
typeOnly: boolean;
|
|
1363
|
+
asserts?: ObjectExpression;
|
|
1364
|
+
}
|
|
1365
|
+
export interface ExportDefaultDeclaration extends Node, HasSpan {
|
|
1366
|
+
type: "ExportDefaultDeclaration";
|
|
1367
|
+
decl: DefaultDecl;
|
|
1368
|
+
}
|
|
1369
|
+
export type DefaultDecl = ClassExpression | FunctionExpression | TsInterfaceDeclaration;
|
|
1370
|
+
export type ImportSpecifier = NamedImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier;
|
|
1371
|
+
/**
|
|
1372
|
+
* e.g. `import foo from 'mod.js'`
|
|
1373
|
+
*/
|
|
1374
|
+
export interface ImportDefaultSpecifier extends Node, HasSpan {
|
|
1375
|
+
type: "ImportDefaultSpecifier";
|
|
1376
|
+
local: Identifier;
|
|
1377
|
+
}
|
|
1378
|
+
/**
|
|
1379
|
+
* e.g. `import * as foo from 'mod.js'`.
|
|
1380
|
+
*/
|
|
1381
|
+
export interface ImportNamespaceSpecifier extends Node, HasSpan {
|
|
1382
|
+
type: "ImportNamespaceSpecifier";
|
|
1383
|
+
local: Identifier;
|
|
1384
|
+
}
|
|
1385
|
+
/**
|
|
1386
|
+
* e.g. - `import { foo } from 'mod.js'`
|
|
1387
|
+
*
|
|
1388
|
+
* local = foo, imported = None
|
|
1389
|
+
*
|
|
1390
|
+
* e.g. `import { foo as bar } from 'mod.js'`
|
|
1391
|
+
*
|
|
1392
|
+
* local = bar, imported = Some(foo) for
|
|
1393
|
+
*/
|
|
1394
|
+
export interface NamedImportSpecifier extends Node, HasSpan {
|
|
1395
|
+
type: "ImportSpecifier";
|
|
1396
|
+
local: Identifier;
|
|
1397
|
+
imported?: ModuleExportName;
|
|
1398
|
+
isTypeOnly: boolean;
|
|
1399
|
+
}
|
|
1400
|
+
export type ModuleExportName = Identifier | StringLiteral;
|
|
1401
|
+
export type ExportSpecifier = ExportNamespaceSpecifier | ExportDefaultSpecifier | NamedExportSpecifier;
|
|
1402
|
+
/**
|
|
1403
|
+
* `export * as foo from 'src';`
|
|
1404
|
+
*/
|
|
1405
|
+
export interface ExportNamespaceSpecifier extends Node, HasSpan {
|
|
1406
|
+
type: "ExportNamespaceSpecifier";
|
|
1407
|
+
name: ModuleExportName;
|
|
1408
|
+
}
|
|
1409
|
+
export interface ExportDefaultSpecifier extends Node, HasSpan {
|
|
1410
|
+
type: "ExportDefaultSpecifier";
|
|
1411
|
+
exported: Identifier;
|
|
1412
|
+
}
|
|
1413
|
+
export interface NamedExportSpecifier extends Node, HasSpan {
|
|
1414
|
+
type: "ExportSpecifier";
|
|
1415
|
+
orig: ModuleExportName;
|
|
1416
|
+
/**
|
|
1417
|
+
* `Some(bar)` in `export { foo as bar }`
|
|
1418
|
+
*/
|
|
1419
|
+
exported?: ModuleExportName;
|
|
1420
|
+
isTypeOnly: boolean;
|
|
1421
|
+
}
|
|
1422
|
+
interface HasInterpreter {
|
|
1423
|
+
/**
|
|
1424
|
+
* e.g. `/usr/bin/node` for `#!/usr/bin/node`
|
|
1425
|
+
*/
|
|
1426
|
+
interpreter: string;
|
|
1427
|
+
}
|
|
1428
|
+
export type Program = Module | Script;
|
|
1429
|
+
export interface Module extends Node, HasSpan, HasInterpreter {
|
|
1430
|
+
type: "Module";
|
|
1431
|
+
body: ModuleItem[];
|
|
1432
|
+
}
|
|
1433
|
+
export interface Script extends Node, HasSpan, HasInterpreter {
|
|
1434
|
+
type: "Script";
|
|
1435
|
+
body: Statement[];
|
|
1436
|
+
}
|
|
1437
|
+
export type ModuleItem = ModuleDeclaration | Statement;
|
|
1438
|
+
export type BinaryOperator = "==" | "!=" | "===" | "!==" | "<" | "<=" | ">" | ">=" | "<<" | ">>" | ">>>" | "+" | "-" | "*" | "/" | "%" | "|" | "^" | "&" | "||" | "&&" | "in" | "instanceof" | "**" | "??";
|
|
1439
|
+
export type AssignmentOperator = "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "<<=" | ">>=" | ">>>=" | "|=" | "^=" | "&=" | "**=" | "&&=" | "||=" | "??=";
|
|
1440
|
+
export type UpdateOperator = "++" | "--";
|
|
1441
|
+
export type UnaryOperator = "-" | "+" | "!" | "~" | "typeof" | "void" | "delete";
|
|
1442
|
+
export type Pattern = BindingIdentifier | ArrayPattern | RestElement | ObjectPattern | AssignmentPattern | Invalid | Expression;
|
|
1443
|
+
export interface BindingIdentifier extends PatternBase {
|
|
1444
|
+
type: "Identifier";
|
|
1445
|
+
value: string;
|
|
1446
|
+
optional: boolean;
|
|
1447
|
+
}
|
|
1448
|
+
export interface ArrayPattern extends PatternBase {
|
|
1449
|
+
type: "ArrayPattern";
|
|
1450
|
+
elements: (Pattern | undefined)[];
|
|
1451
|
+
optional: boolean;
|
|
1452
|
+
}
|
|
1453
|
+
export interface ObjectPattern extends PatternBase {
|
|
1454
|
+
type: "ObjectPattern";
|
|
1455
|
+
properties: ObjectPatternProperty[];
|
|
1456
|
+
optional: boolean;
|
|
1457
|
+
}
|
|
1458
|
+
export interface AssignmentPattern extends PatternBase {
|
|
1459
|
+
type: "AssignmentPattern";
|
|
1460
|
+
left: Pattern;
|
|
1461
|
+
right: Expression;
|
|
1462
|
+
}
|
|
1463
|
+
export interface RestElement extends PatternBase {
|
|
1464
|
+
type: "RestElement";
|
|
1465
|
+
rest: Span;
|
|
1466
|
+
argument: Pattern;
|
|
1467
|
+
}
|
|
1468
|
+
export type ObjectPatternProperty = KeyValuePatternProperty | AssignmentPatternProperty | RestElement;
|
|
1469
|
+
/**
|
|
1470
|
+
* `{key: value}`
|
|
1471
|
+
*/
|
|
1472
|
+
export interface KeyValuePatternProperty extends Node {
|
|
1473
|
+
type: "KeyValuePatternProperty";
|
|
1474
|
+
key: PropertyName;
|
|
1475
|
+
value: Pattern;
|
|
1476
|
+
}
|
|
1477
|
+
/**
|
|
1478
|
+
* `{key}` or `{key = value}`
|
|
1479
|
+
*/
|
|
1480
|
+
export interface AssignmentPatternProperty extends Node, HasSpan {
|
|
1481
|
+
type: "AssignmentPatternProperty";
|
|
1482
|
+
key: Identifier;
|
|
1483
|
+
value?: Expression;
|
|
1484
|
+
}
|
|
1485
|
+
/** Identifier is `a` in `{ a, }` */
|
|
1486
|
+
export type Property = Identifier | KeyValueProperty | AssignmentProperty | GetterProperty | SetterProperty | MethodProperty;
|
|
1487
|
+
interface PropBase extends Node {
|
|
1488
|
+
key: PropertyName;
|
|
1489
|
+
}
|
|
1490
|
+
export interface KeyValueProperty extends PropBase {
|
|
1491
|
+
type: "KeyValueProperty";
|
|
1492
|
+
value: Expression;
|
|
1493
|
+
}
|
|
1494
|
+
export interface AssignmentProperty extends Node {
|
|
1495
|
+
type: "AssignmentProperty";
|
|
1496
|
+
key: Identifier;
|
|
1497
|
+
value: Expression;
|
|
1498
|
+
}
|
|
1499
|
+
export interface GetterProperty extends PropBase, HasSpan {
|
|
1500
|
+
type: "GetterProperty";
|
|
1501
|
+
typeAnnotation?: TsTypeAnnotation;
|
|
1502
|
+
body?: BlockStatement;
|
|
1503
|
+
}
|
|
1504
|
+
export interface SetterProperty extends PropBase, HasSpan {
|
|
1505
|
+
type: "SetterProperty";
|
|
1506
|
+
param: Pattern;
|
|
1507
|
+
body?: BlockStatement;
|
|
1508
|
+
}
|
|
1509
|
+
export interface MethodProperty extends PropBase, Fn {
|
|
1510
|
+
type: "MethodProperty";
|
|
1511
|
+
}
|
|
1512
|
+
export type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropName | BigIntLiteral;
|
|
1513
|
+
export interface ComputedPropName extends Node, HasSpan {
|
|
1514
|
+
type: "Computed";
|
|
1515
|
+
expression: Expression;
|
|
1516
|
+
}
|
|
1517
|
+
export interface BlockStatement extends Node, HasSpan {
|
|
1518
|
+
type: "BlockStatement";
|
|
1519
|
+
stmts: Statement[];
|
|
1520
|
+
}
|
|
1521
|
+
export interface ExpressionStatement extends Node, HasSpan {
|
|
1522
|
+
type: "ExpressionStatement";
|
|
1523
|
+
expression: Expression;
|
|
1524
|
+
}
|
|
1525
|
+
export type Statement = BlockStatement | EmptyStatement | DebuggerStatement | WithStatement | ReturnStatement | LabeledStatement | BreakStatement | ContinueStatement | IfStatement | SwitchStatement | ThrowStatement | TryStatement | WhileStatement | DoWhileStatement | ForStatement | ForInStatement | ForOfStatement | Declaration | ExpressionStatement;
|
|
1526
|
+
export interface EmptyStatement extends Node, HasSpan {
|
|
1527
|
+
type: "EmptyStatement";
|
|
1528
|
+
}
|
|
1529
|
+
export interface DebuggerStatement extends Node, HasSpan {
|
|
1530
|
+
type: "DebuggerStatement";
|
|
1531
|
+
}
|
|
1532
|
+
export interface WithStatement extends Node, HasSpan {
|
|
1533
|
+
type: "WithStatement";
|
|
1534
|
+
object: Expression;
|
|
1535
|
+
body: Statement;
|
|
1536
|
+
}
|
|
1537
|
+
export interface ReturnStatement extends Node, HasSpan {
|
|
1538
|
+
type: "ReturnStatement";
|
|
1539
|
+
argument?: Expression;
|
|
1540
|
+
}
|
|
1541
|
+
export interface LabeledStatement extends Node, HasSpan {
|
|
1542
|
+
type: "LabeledStatement";
|
|
1543
|
+
label: Identifier;
|
|
1544
|
+
body: Statement;
|
|
1545
|
+
}
|
|
1546
|
+
export interface BreakStatement extends Node, HasSpan {
|
|
1547
|
+
type: "BreakStatement";
|
|
1548
|
+
label?: Identifier;
|
|
1549
|
+
}
|
|
1550
|
+
export interface ContinueStatement extends Node, HasSpan {
|
|
1551
|
+
type: "ContinueStatement";
|
|
1552
|
+
label?: Identifier;
|
|
1553
|
+
}
|
|
1554
|
+
export interface IfStatement extends Node, HasSpan {
|
|
1555
|
+
type: "IfStatement";
|
|
1556
|
+
test: Expression;
|
|
1557
|
+
consequent: Statement;
|
|
1558
|
+
alternate?: Statement;
|
|
1559
|
+
}
|
|
1560
|
+
export interface SwitchStatement extends Node, HasSpan {
|
|
1561
|
+
type: "SwitchStatement";
|
|
1562
|
+
discriminant: Expression;
|
|
1563
|
+
cases: SwitchCase[];
|
|
1564
|
+
}
|
|
1565
|
+
export interface ThrowStatement extends Node, HasSpan {
|
|
1566
|
+
type: "ThrowStatement";
|
|
1567
|
+
argument: Expression;
|
|
1568
|
+
}
|
|
1569
|
+
export interface TryStatement extends Node, HasSpan {
|
|
1570
|
+
type: "TryStatement";
|
|
1571
|
+
block: BlockStatement;
|
|
1572
|
+
handler?: CatchClause;
|
|
1573
|
+
finalizer?: BlockStatement;
|
|
1574
|
+
}
|
|
1575
|
+
export interface WhileStatement extends Node, HasSpan {
|
|
1576
|
+
type: "WhileStatement";
|
|
1577
|
+
test: Expression;
|
|
1578
|
+
body: Statement;
|
|
1579
|
+
}
|
|
1580
|
+
export interface DoWhileStatement extends Node, HasSpan {
|
|
1581
|
+
type: "DoWhileStatement";
|
|
1582
|
+
test: Expression;
|
|
1583
|
+
body: Statement;
|
|
1584
|
+
}
|
|
1585
|
+
export interface ForStatement extends Node, HasSpan {
|
|
1586
|
+
type: "ForStatement";
|
|
1587
|
+
init?: VariableDeclaration | Expression;
|
|
1588
|
+
test?: Expression;
|
|
1589
|
+
update?: Expression;
|
|
1590
|
+
body: Statement;
|
|
1591
|
+
}
|
|
1592
|
+
export interface ForInStatement extends Node, HasSpan {
|
|
1593
|
+
type: "ForInStatement";
|
|
1594
|
+
left: VariableDeclaration | Pattern;
|
|
1595
|
+
right: Expression;
|
|
1596
|
+
body: Statement;
|
|
1597
|
+
}
|
|
1598
|
+
export interface ForOfStatement extends Node, HasSpan {
|
|
1599
|
+
type: "ForOfStatement";
|
|
1600
|
+
/**
|
|
1601
|
+
* Span of the await token.
|
|
1602
|
+
*
|
|
1603
|
+
* es2018 for-await-of statements, e.g., `for await (const x of xs) {`
|
|
1604
|
+
*/
|
|
1605
|
+
await?: Span;
|
|
1606
|
+
left: VariableDeclaration | Pattern;
|
|
1607
|
+
right: Expression;
|
|
1608
|
+
body: Statement;
|
|
1609
|
+
}
|
|
1610
|
+
export interface SwitchCase extends Node, HasSpan {
|
|
1611
|
+
type: "SwitchCase";
|
|
1612
|
+
/**
|
|
1613
|
+
* Undefined for default case
|
|
1614
|
+
*/
|
|
1615
|
+
test?: Expression;
|
|
1616
|
+
consequent: Statement[];
|
|
1617
|
+
}
|
|
1618
|
+
export interface CatchClause extends Node, HasSpan {
|
|
1619
|
+
type: "CatchClause";
|
|
1620
|
+
/**
|
|
1621
|
+
* The param is `undefined` if the catch binding is omitted. E.g., `try { foo() } catch {}`
|
|
1622
|
+
*/
|
|
1623
|
+
param?: Pattern;
|
|
1624
|
+
body: BlockStatement;
|
|
1625
|
+
}
|
|
1626
|
+
export interface TsTypeAnnotation extends Node, HasSpan {
|
|
1627
|
+
type: "TsTypeAnnotation";
|
|
1628
|
+
typeAnnotation: TsType;
|
|
1629
|
+
}
|
|
1630
|
+
export interface TsTypeParameterDeclaration extends Node, HasSpan {
|
|
1631
|
+
type: "TsTypeParameterDeclaration";
|
|
1632
|
+
parameters: TsTypeParameter[];
|
|
1633
|
+
}
|
|
1634
|
+
export interface TsTypeParameter extends Node, HasSpan {
|
|
1635
|
+
type: "TsTypeParameter";
|
|
1636
|
+
name: Identifier;
|
|
1637
|
+
in: boolean;
|
|
1638
|
+
out: boolean;
|
|
1639
|
+
constraint?: TsType;
|
|
1640
|
+
default?: TsType;
|
|
1641
|
+
}
|
|
1642
|
+
export interface TsTypeParameterInstantiation extends Node, HasSpan {
|
|
1643
|
+
type: "TsTypeParameterInstantiation";
|
|
1644
|
+
params: TsType[];
|
|
1645
|
+
}
|
|
1646
|
+
export interface TsParameterProperty extends Node, HasSpan, HasDecorator {
|
|
1647
|
+
type: "TsParameterProperty";
|
|
1648
|
+
accessibility?: Accessibility;
|
|
1649
|
+
override: boolean;
|
|
1650
|
+
readonly: boolean;
|
|
1651
|
+
param: TsParameterPropertyParameter;
|
|
1652
|
+
}
|
|
1653
|
+
export type TsParameterPropertyParameter = BindingIdentifier | AssignmentPattern;
|
|
1654
|
+
export interface TsQualifiedName extends Node {
|
|
1655
|
+
type: "TsQualifiedName";
|
|
1656
|
+
left: TsEntityName;
|
|
1657
|
+
right: Identifier;
|
|
1658
|
+
}
|
|
1659
|
+
export type TsEntityName = TsQualifiedName | Identifier;
|
|
1660
|
+
export type TsTypeElement = TsCallSignatureDeclaration | TsConstructSignatureDeclaration | TsPropertySignature | TsGetterSignature | TsSetterSignature | TsMethodSignature | TsIndexSignature;
|
|
1661
|
+
export interface TsCallSignatureDeclaration extends Node, HasSpan {
|
|
1662
|
+
type: "TsCallSignatureDeclaration";
|
|
1663
|
+
params: TsFnParameter[];
|
|
1664
|
+
typeAnnotation?: TsTypeAnnotation;
|
|
1665
|
+
typeParams?: TsTypeParameterDeclaration;
|
|
1666
|
+
}
|
|
1667
|
+
export interface TsConstructSignatureDeclaration extends Node, HasSpan {
|
|
1668
|
+
type: "TsConstructSignatureDeclaration";
|
|
1669
|
+
params: TsFnParameter[];
|
|
1670
|
+
typeAnnotation?: TsTypeAnnotation;
|
|
1671
|
+
typeParams?: TsTypeParameterDeclaration;
|
|
1672
|
+
}
|
|
1673
|
+
export interface TsPropertySignature extends Node, HasSpan {
|
|
1674
|
+
type: "TsPropertySignature";
|
|
1675
|
+
readonly: boolean;
|
|
1676
|
+
key: Expression;
|
|
1677
|
+
computed: boolean;
|
|
1678
|
+
optional: boolean;
|
|
1679
|
+
init?: Expression;
|
|
1680
|
+
params: TsFnParameter[];
|
|
1681
|
+
typeAnnotation?: TsTypeAnnotation;
|
|
1682
|
+
typeParams?: TsTypeParameterDeclaration;
|
|
1683
|
+
}
|
|
1684
|
+
export interface TsGetterSignature extends Node, HasSpan {
|
|
1685
|
+
type: "TsGetterSignature";
|
|
1686
|
+
readonly: boolean;
|
|
1687
|
+
key: Expression;
|
|
1688
|
+
computed: boolean;
|
|
1689
|
+
optional: boolean;
|
|
1690
|
+
typeAnnotation?: TsTypeAnnotation;
|
|
1691
|
+
}
|
|
1692
|
+
export interface TsSetterSignature extends Node, HasSpan {
|
|
1693
|
+
type: "TsSetterSignature";
|
|
1694
|
+
readonly: boolean;
|
|
1695
|
+
key: Expression;
|
|
1696
|
+
computed: boolean;
|
|
1697
|
+
optional: boolean;
|
|
1698
|
+
param: TsFnParameter;
|
|
1699
|
+
}
|
|
1700
|
+
export interface TsMethodSignature extends Node, HasSpan {
|
|
1701
|
+
type: "TsMethodSignature";
|
|
1702
|
+
readonly: boolean;
|
|
1703
|
+
key: Expression;
|
|
1704
|
+
computed: boolean;
|
|
1705
|
+
optional: boolean;
|
|
1706
|
+
params: TsFnParameter[];
|
|
1707
|
+
typeAnn?: TsTypeAnnotation;
|
|
1708
|
+
typeParams?: TsTypeParameterDeclaration;
|
|
1709
|
+
}
|
|
1710
|
+
export interface TsIndexSignature extends Node, HasSpan {
|
|
1711
|
+
type: "TsIndexSignature";
|
|
1712
|
+
params: TsFnParameter[];
|
|
1713
|
+
typeAnnotation?: TsTypeAnnotation;
|
|
1714
|
+
readonly: boolean;
|
|
1715
|
+
static: boolean;
|
|
1716
|
+
}
|
|
1717
|
+
export type TsType = TsKeywordType | TsThisType | TsFnOrConstructorType | TsTypeReference | TsTypeQuery | TsTypeLiteral | TsArrayType | TsTupleType | TsOptionalType | TsRestType | TsUnionOrIntersectionType | TsConditionalType | TsInferType | TsParenthesizedType | TsTypeOperator | TsIndexedAccessType | TsMappedType | TsLiteralType | TsTypePredicate | TsImportType;
|
|
1718
|
+
export type TsFnOrConstructorType = TsFunctionType | TsConstructorType;
|
|
1719
|
+
export interface TsKeywordType extends Node, HasSpan {
|
|
1720
|
+
type: "TsKeywordType";
|
|
1721
|
+
kind: TsKeywordTypeKind;
|
|
1722
|
+
}
|
|
1723
|
+
export type TsKeywordTypeKind = "any" | "unknown" | "number" | "object" | "boolean" | "bigint" | "string" | "symbol" | "void" | "undefined" | "null" | "never" | "intrinsic";
|
|
1724
|
+
export interface TsThisType extends Node, HasSpan {
|
|
1725
|
+
type: "TsThisType";
|
|
1726
|
+
}
|
|
1727
|
+
export type TsFnParameter = BindingIdentifier | ArrayPattern | RestElement | ObjectPattern;
|
|
1728
|
+
export interface TsFunctionType extends Node, HasSpan {
|
|
1729
|
+
type: "TsFunctionType";
|
|
1730
|
+
params: TsFnParameter[];
|
|
1731
|
+
typeParams?: TsTypeParameterDeclaration;
|
|
1732
|
+
typeAnnotation: TsTypeAnnotation;
|
|
1733
|
+
}
|
|
1734
|
+
export interface TsConstructorType extends Node, HasSpan {
|
|
1735
|
+
type: "TsConstructorType";
|
|
1736
|
+
params: TsFnParameter[];
|
|
1737
|
+
typeParams?: TsTypeParameterDeclaration;
|
|
1738
|
+
typeAnnotation: TsTypeAnnotation;
|
|
1739
|
+
isAbstract: boolean;
|
|
1740
|
+
}
|
|
1741
|
+
export interface TsTypeReference extends Node, HasSpan {
|
|
1742
|
+
type: "TsTypeReference";
|
|
1743
|
+
typeName: TsEntityName;
|
|
1744
|
+
typeParams?: TsTypeParameterInstantiation;
|
|
1745
|
+
}
|
|
1746
|
+
export interface TsTypePredicate extends Node, HasSpan {
|
|
1747
|
+
type: "TsTypePredicate";
|
|
1748
|
+
asserts: boolean;
|
|
1749
|
+
paramName: TsThisTypeOrIdent;
|
|
1750
|
+
typeAnnotation?: TsTypeAnnotation;
|
|
1751
|
+
}
|
|
1752
|
+
export type TsThisTypeOrIdent = TsThisType | Identifier;
|
|
1753
|
+
export interface TsImportType extends Node, HasSpan {
|
|
1754
|
+
type: "TsImportType";
|
|
1755
|
+
argument: StringLiteral;
|
|
1756
|
+
qualifier?: TsEntityName;
|
|
1757
|
+
typeArguments?: TsTypeParameterInstantiation;
|
|
1758
|
+
}
|
|
1759
|
+
/**
|
|
1760
|
+
* `typeof` operator
|
|
1761
|
+
*/
|
|
1762
|
+
export interface TsTypeQuery extends Node, HasSpan {
|
|
1763
|
+
type: "TsTypeQuery";
|
|
1764
|
+
exprName: TsTypeQueryExpr;
|
|
1765
|
+
typeArguments?: TsTypeParameterInstantiation;
|
|
1766
|
+
}
|
|
1767
|
+
export type TsTypeQueryExpr = TsEntityName | TsImportType;
|
|
1768
|
+
export interface TsTypeLiteral extends Node, HasSpan {
|
|
1769
|
+
type: "TsTypeLiteral";
|
|
1770
|
+
members: TsTypeElement[];
|
|
1771
|
+
}
|
|
1772
|
+
export interface TsArrayType extends Node, HasSpan {
|
|
1773
|
+
type: "TsArrayType";
|
|
1774
|
+
elemType: TsType;
|
|
1775
|
+
}
|
|
1776
|
+
export interface TsTupleType extends Node, HasSpan {
|
|
1777
|
+
type: "TsTupleType";
|
|
1778
|
+
elemTypes: TsTupleElement[];
|
|
1779
|
+
}
|
|
1780
|
+
export interface TsTupleElement extends Node, HasSpan {
|
|
1781
|
+
type: "TsTupleElement";
|
|
1782
|
+
label?: Pattern;
|
|
1783
|
+
ty: TsType;
|
|
1784
|
+
}
|
|
1785
|
+
export interface TsOptionalType extends Node, HasSpan {
|
|
1786
|
+
type: "TsOptionalType";
|
|
1787
|
+
typeAnnotation: TsType;
|
|
1788
|
+
}
|
|
1789
|
+
export interface TsRestType extends Node, HasSpan {
|
|
1790
|
+
type: "TsRestType";
|
|
1791
|
+
typeAnnotation: TsType;
|
|
1792
|
+
}
|
|
1793
|
+
export type TsUnionOrIntersectionType = TsUnionType | TsIntersectionType;
|
|
1794
|
+
export interface TsUnionType extends Node, HasSpan {
|
|
1795
|
+
type: "TsUnionType";
|
|
1796
|
+
types: TsType[];
|
|
1797
|
+
}
|
|
1798
|
+
export interface TsIntersectionType extends Node, HasSpan {
|
|
1799
|
+
type: "TsIntersectionType";
|
|
1800
|
+
types: TsType[];
|
|
1801
|
+
}
|
|
1802
|
+
export interface TsConditionalType extends Node, HasSpan {
|
|
1803
|
+
type: "TsConditionalType";
|
|
1804
|
+
checkType: TsType;
|
|
1805
|
+
extendsType: TsType;
|
|
1806
|
+
trueType: TsType;
|
|
1807
|
+
falseType: TsType;
|
|
1808
|
+
}
|
|
1809
|
+
export interface TsInferType extends Node, HasSpan {
|
|
1810
|
+
type: "TsInferType";
|
|
1811
|
+
typeParam: TsTypeParameter;
|
|
1812
|
+
}
|
|
1813
|
+
export interface TsParenthesizedType extends Node, HasSpan {
|
|
1814
|
+
type: "TsParenthesizedType";
|
|
1815
|
+
typeAnnotation: TsType;
|
|
1816
|
+
}
|
|
1817
|
+
export interface TsTypeOperator extends Node, HasSpan {
|
|
1818
|
+
type: "TsTypeOperator";
|
|
1819
|
+
op: TsTypeOperatorOp;
|
|
1820
|
+
typeAnnotation: TsType;
|
|
1821
|
+
}
|
|
1822
|
+
export type TsTypeOperatorOp = "keyof" | "unique" | "readonly";
|
|
1823
|
+
export interface TsIndexedAccessType extends Node, HasSpan {
|
|
1824
|
+
type: "TsIndexedAccessType";
|
|
1825
|
+
readonly: boolean;
|
|
1826
|
+
objectType: TsType;
|
|
1827
|
+
indexType: TsType;
|
|
1828
|
+
}
|
|
1829
|
+
export type TruePlusMinus = true | "+" | "-";
|
|
1830
|
+
export interface TsMappedType extends Node, HasSpan {
|
|
1831
|
+
type: "TsMappedType";
|
|
1832
|
+
readonly?: TruePlusMinus;
|
|
1833
|
+
typeParam: TsTypeParameter;
|
|
1834
|
+
nameType?: TsType;
|
|
1835
|
+
optional?: TruePlusMinus;
|
|
1836
|
+
typeAnnotation?: TsType;
|
|
1837
|
+
}
|
|
1838
|
+
export interface TsLiteralType extends Node, HasSpan {
|
|
1839
|
+
type: "TsLiteralType";
|
|
1840
|
+
literal: TsLiteral;
|
|
1841
|
+
}
|
|
1842
|
+
export type TsLiteral = NumericLiteral | StringLiteral | BooleanLiteral | BigIntLiteral | TsTemplateLiteralType;
|
|
1843
|
+
export interface TsTemplateLiteralType extends Node, HasSpan {
|
|
1844
|
+
type: "TemplateLiteral";
|
|
1845
|
+
types: TsType[];
|
|
1846
|
+
quasis: TemplateElement[];
|
|
1847
|
+
}
|
|
1848
|
+
export interface TsInterfaceDeclaration extends Node, HasSpan {
|
|
1849
|
+
type: "TsInterfaceDeclaration";
|
|
1850
|
+
id: Identifier;
|
|
1851
|
+
declare: boolean;
|
|
1852
|
+
typeParams?: TsTypeParameterDeclaration;
|
|
1853
|
+
extends: TsExpressionWithTypeArguments[];
|
|
1854
|
+
body: TsInterfaceBody;
|
|
1855
|
+
}
|
|
1856
|
+
export interface TsInterfaceBody extends Node, HasSpan {
|
|
1857
|
+
type: "TsInterfaceBody";
|
|
1858
|
+
body: TsTypeElement[];
|
|
1859
|
+
}
|
|
1860
|
+
export interface TsExpressionWithTypeArguments extends Node, HasSpan {
|
|
1861
|
+
type: "TsExpressionWithTypeArguments";
|
|
1862
|
+
expression: Expression;
|
|
1863
|
+
typeArguments?: TsTypeParameterInstantiation;
|
|
1864
|
+
}
|
|
1865
|
+
export interface TsTypeAliasDeclaration extends Node, HasSpan {
|
|
1866
|
+
type: "TsTypeAliasDeclaration";
|
|
1867
|
+
declare: boolean;
|
|
1868
|
+
id: Identifier;
|
|
1869
|
+
typeParams?: TsTypeParameterDeclaration;
|
|
1870
|
+
typeAnnotation: TsType;
|
|
1871
|
+
}
|
|
1872
|
+
export interface TsEnumDeclaration extends Node, HasSpan {
|
|
1873
|
+
type: "TsEnumDeclaration";
|
|
1874
|
+
declare: boolean;
|
|
1875
|
+
isConst: boolean;
|
|
1876
|
+
id: Identifier;
|
|
1877
|
+
members: TsEnumMember[];
|
|
1878
|
+
}
|
|
1879
|
+
export interface TsEnumMember extends Node, HasSpan {
|
|
1880
|
+
type: "TsEnumMember";
|
|
1881
|
+
id: TsEnumMemberId;
|
|
1882
|
+
init?: Expression;
|
|
1883
|
+
}
|
|
1884
|
+
export type TsEnumMemberId = Identifier | StringLiteral;
|
|
1885
|
+
export interface TsModuleDeclaration extends Node, HasSpan {
|
|
1886
|
+
type: "TsModuleDeclaration";
|
|
1887
|
+
declare: boolean;
|
|
1888
|
+
global: boolean;
|
|
1889
|
+
id: TsModuleName;
|
|
1890
|
+
body?: TsNamespaceBody;
|
|
1891
|
+
}
|
|
1892
|
+
/**
|
|
1893
|
+
* `namespace A.B { }` is a namespace named `A` with another TsNamespaceDecl as its body.
|
|
1894
|
+
*/
|
|
1895
|
+
export type TsNamespaceBody = TsModuleBlock | TsNamespaceDeclaration;
|
|
1896
|
+
export interface TsModuleBlock extends Node, HasSpan {
|
|
1897
|
+
type: "TsModuleBlock";
|
|
1898
|
+
body: ModuleItem[];
|
|
1899
|
+
}
|
|
1900
|
+
export interface TsNamespaceDeclaration extends Node, HasSpan {
|
|
1901
|
+
type: "TsNamespaceDeclaration";
|
|
1902
|
+
declare: boolean;
|
|
1903
|
+
global: boolean;
|
|
1904
|
+
id: Identifier;
|
|
1905
|
+
body: TsNamespaceBody;
|
|
1906
|
+
}
|
|
1907
|
+
export type TsModuleName = Identifier | StringLiteral;
|
|
1908
|
+
export interface TsImportEqualsDeclaration extends Node, HasSpan {
|
|
1909
|
+
type: "TsImportEqualsDeclaration";
|
|
1910
|
+
declare: boolean;
|
|
1911
|
+
isExport: boolean;
|
|
1912
|
+
isTypeOnly: boolean;
|
|
1913
|
+
id: Identifier;
|
|
1914
|
+
moduleRef: TsModuleReference;
|
|
1915
|
+
}
|
|
1916
|
+
export type TsModuleReference = TsEntityName | TsExternalModuleReference;
|
|
1917
|
+
export interface TsExternalModuleReference extends Node, HasSpan {
|
|
1918
|
+
type: "TsExternalModuleReference";
|
|
1919
|
+
expression: StringLiteral;
|
|
1920
|
+
}
|
|
1921
|
+
export interface TsExportAssignment extends Node, HasSpan {
|
|
1922
|
+
type: "TsExportAssignment";
|
|
1923
|
+
expression: Expression;
|
|
1924
|
+
}
|
|
1925
|
+
export interface TsNamespaceExportDeclaration extends Node, HasSpan {
|
|
1926
|
+
type: "TsNamespaceExportDeclaration";
|
|
1927
|
+
id: Identifier;
|
|
1928
|
+
}
|
|
1929
|
+
export interface TsAsExpression extends ExpressionBase {
|
|
1930
|
+
type: "TsAsExpression";
|
|
1931
|
+
expression: Expression;
|
|
1932
|
+
typeAnnotation: TsType;
|
|
1933
|
+
}
|
|
1934
|
+
export interface TsSatisfiesExpression extends ExpressionBase {
|
|
1935
|
+
type: "TsSatisfiesExpression";
|
|
1936
|
+
expression: Expression;
|
|
1937
|
+
typeAnnotation: TsType;
|
|
1938
|
+
}
|
|
1939
|
+
export interface TsInstantiation extends Node, HasSpan {
|
|
1940
|
+
type: "TsInstantiation";
|
|
1941
|
+
expression: Expression;
|
|
1942
|
+
typeArguments: TsTypeParameterInstantiation;
|
|
1943
|
+
}
|
|
1944
|
+
export interface TsTypeAssertion extends ExpressionBase {
|
|
1945
|
+
type: "TsTypeAssertion";
|
|
1946
|
+
expression: Expression;
|
|
1947
|
+
typeAnnotation: TsType;
|
|
1948
|
+
}
|
|
1949
|
+
export interface TsConstAssertion extends ExpressionBase {
|
|
1950
|
+
type: "TsConstAssertion";
|
|
1951
|
+
expression: Expression;
|
|
1952
|
+
}
|
|
1953
|
+
export interface TsNonNullExpression extends ExpressionBase {
|
|
1954
|
+
type: "TsNonNullExpression";
|
|
1955
|
+
expression: Expression;
|
|
1956
|
+
}
|
|
1957
|
+
export type Accessibility = "public" | "protected" | "private";
|
|
1958
|
+
export interface Invalid extends Node, HasSpan {
|
|
1959
|
+
type: "Invalid";
|
|
1960
|
+
}
|
|
1961
|
+
export {};
|
|
1962
|
+
//# sourceMappingURL=index.d.ts.map
|