@swc/wasm 1.2.220 → 1.2.223

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 (4) hide show
  1. package/package.json +1 -1
  2. package/wasm.d.ts +2822 -27
  3. package/wasm.js +219 -59
  4. package/wasm_bg.wasm +0 -0
package/wasm.d.ts CHANGED
@@ -1,32 +1,2827 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+
4
+ export function minify(src: string, opts?: JsMinifyOptions): Promise<Output>;
5
+ export function minifySync(code: string, opts?: JsMinifyOptions): Output;
6
+
7
+ export function parse(src: string, options: ParseOptions & {
8
+ isModule: false;
9
+ }): Promise<Script>;
10
+ export function parse(src: string, options?: ParseOptions): Promise<Module>;
11
+ export function parseSync(src: string, options: ParseOptions & {
12
+ isModule: false;
13
+ }): Script;
14
+ export function parseSync(src: string, options?: ParseOptions): Module;
15
+
16
+ export function print(m: Program, options?: Options): Promise<Output>;
17
+ export function printSync(m: Program, options?: Options): Output
18
+
19
+ /**
20
+ * Note: this interface currently does not do _actual_ async work, only provides
21
+ * a corresponding async interfaces to the `@swc/core`'s interface.
22
+ */
23
+ export function transform(
24
+ code: string | Program,
25
+ options?: Options,
26
+ experimental_plugin_bytes_resolver?: any
27
+ ): Promise<Output>;
28
+ /**
29
+ * @param {string} code
30
+ * @param {Options} opts
31
+ * @param {Record<string, ArrayBuffer>} experimental_plugin_bytes_resolver An object contains bytes array for the plugin
32
+ * specified in config. Key of record represents the name of the plugin specified in config. Note this is an experimental
33
+ * interface, likely will change.
34
+ * @returns {Output}
35
+ */
36
+ export function transformSync(code: string | Program, opts?: Options, experimental_plugin_bytes_resolver?: any): Output;
37
+
38
+
39
+
40
+ export interface Plugin {
41
+ (module: Program): Program;
42
+ }
43
+
44
+ // TODO:
45
+ export type ParseOptions = ParserConfig & {
46
+ comments?: boolean;
47
+ script?: boolean;
48
+ /**
49
+ * Defaults to es3.
50
+ */
51
+ target?: JscTarget;
52
+ };
53
+
54
+ export type TerserEcmaVersion = 5 | 2015 | 2016 | string | number;
55
+
56
+ export interface JsMinifyOptions {
57
+ compress?: TerserCompressOptions | boolean,
58
+
59
+ format?: JsFormatOptions & ToSnakeCaseProperties<JsFormatOptions>,
60
+
61
+ mangle?: TerserMangleOptions | boolean,
62
+
63
+ ecma?: TerserEcmaVersion,
64
+
65
+ keep_classnames?: boolean,
66
+
67
+ keep_fnames?: boolean,
68
+
69
+ module?: boolean,
70
+
71
+ safari10?: boolean
72
+
73
+ toplevel?: boolean
74
+
75
+ sourceMap?: boolean
76
+
77
+ outputPath?: string
78
+
79
+ inlineSourcesContent?: boolean
80
+ }
81
+
82
+ /**
83
+ * @example ToSnakeCase<'indentLevel'> == 'indent_level'
84
+ */
85
+ type ToSnakeCase<T extends string> = T extends `${infer A}${infer B}`
86
+ ? `${A extends Lowercase<A> ? A : `_${Lowercase<A>}`}${ToSnakeCase<B>}`
87
+ : T
88
+
89
+ /**
90
+ * @example ToSnakeCaseProperties<{indentLevel: 3}> == {indent_level: 3}
91
+ */
92
+ type ToSnakeCaseProperties<T> = {
93
+ [K in keyof T as (K extends string ? ToSnakeCase<K> : K)]: T[K]
94
+ }
95
+
96
+ /**
97
+ * These properties are mostly not implemented yet,
98
+ * but it exists to support passing terser config to swc minify
99
+ * without modification.
100
+ */
101
+ export interface JsFormatOptions {
102
+ /**
103
+ * Currently noop.
104
+ * @default false
105
+ * @alias ascii_only
106
+ */
107
+ asciiOnly?: boolean
108
+
109
+ /**
110
+ * Currently noop.
111
+ * @default false
112
+ */
113
+ beautify?: boolean
114
+
115
+ /**
116
+ * Currently noop.
117
+ * @default false
118
+ */
119
+ braces?: boolean
120
+
121
+ /**
122
+ * - `false`: removes all comments
123
+ * - `'some'`: preserves some comments
124
+ * - `'all'`: preserves all comments
125
+ * @default false
126
+ */
127
+ comments?: false | 'some' | 'all'
128
+
129
+ /**
130
+ * Currently noop.
131
+ * @default 5
132
+ */
133
+ ecma?: TerserEcmaVersion
134
+
135
+ /**
136
+ * Currently noop.
137
+ * @alias indent_level
138
+ */
139
+ indentLevel?: number
140
+
141
+ /**
142
+ * Currently noop.
143
+ * @alias indent_start
144
+ */
145
+ indentStart?: number
146
+
147
+ /**
148
+ * Currently noop.
149
+ * @alias inline_script
150
+ */
151
+ inlineScript?: number
152
+
153
+ /**
154
+ * Currently noop.
155
+ * @alias keep_numbers
156
+ */
157
+ keepNumbers?: number
158
+
159
+ /**
160
+ * Currently noop.
161
+ * @alias keep_quoted_props
162
+ */
163
+ keepQuotedProps?: boolean
164
+
165
+ /**
166
+ * Currently noop.
167
+ * @alias max_line_len
168
+ */
169
+ maxLineLen?: number | false
170
+
171
+ /**
172
+ * Currently noop.
173
+ */
174
+ preamble?: string
175
+
176
+ /**
177
+ * Currently noop.
178
+ * @alias quote_keys
179
+ */
180
+ quoteKeys?: boolean
181
+
182
+ /**
183
+ * Currently noop.
184
+ * @alias quote_style
185
+ */
186
+ quoteStyle?: boolean
187
+
188
+ /**
189
+ * Currently noop.
190
+ * @alias preserve_annotations
191
+ */
192
+ preserveAnnotations?: boolean
193
+
194
+ /**
195
+ * Currently noop.
196
+ */
197
+ safari10?: boolean
198
+
199
+ /**
200
+ * Currently noop.
201
+ */
202
+ semicolons?: boolean
203
+
204
+ /**
205
+ * Currently noop.
206
+ */
207
+ shebang?: boolean
208
+
209
+ /**
210
+ * Currently noop.
211
+ */
212
+ webkit?: boolean
213
+
214
+ /**
215
+ * Currently noop.
216
+ * @alias wrap_iife
217
+ */
218
+ wrapIife?: boolean
219
+
220
+ /**
221
+ * Currently noop.
222
+ * @alias wrap_func_args
223
+ */
224
+ wrapFuncArgs?: boolean
225
+ }
226
+
227
+ export interface TerserCompressOptions {
228
+ arguments?: boolean,
229
+ arrows?: boolean,
230
+
231
+
232
+ booleans?: boolean,
233
+
234
+
235
+ booleans_as_integers?: boolean,
236
+
237
+
238
+ collapse_vars?: boolean,
239
+
240
+
241
+ comparisons?: boolean,
242
+
243
+
244
+ computed_props?: boolean,
245
+
246
+
247
+ conditionals?: boolean,
248
+
249
+
250
+ dead_code?: boolean,
251
+
252
+ defaults?: boolean,
253
+
254
+
255
+ directives?: boolean,
256
+
257
+
258
+ drop_console?: boolean,
259
+
260
+
261
+ drop_debugger?: boolean,
262
+
263
+ ecma?: TerserEcmaVersion,
264
+
265
+
266
+ evaluate?: boolean,
267
+
268
+
269
+ expression?: boolean,
270
+
271
+
272
+ global_defs?: any,
273
+
274
+
275
+ hoist_funs?: boolean,
276
+
277
+
278
+ hoist_props?: boolean,
279
+
280
+
281
+ hoist_vars?: boolean,
282
+
283
+
284
+ ie8?: boolean,
285
+
286
+
287
+ if_return?: boolean,
288
+
289
+
290
+ inline?: 0 | 1 | 2 | 3
291
+
292
+
293
+ join_vars?: boolean,
294
+
295
+
296
+ keep_classnames?: boolean,
297
+
298
+
299
+ keep_fargs?: boolean,
300
+
301
+
302
+ keep_fnames?: boolean,
303
+
304
+
305
+ keep_infinity?: boolean,
306
+
307
+
308
+ loops?: boolean,
309
+ // module : false,
310
+
311
+ negate_iife?: boolean,
312
+
313
+
314
+ passes?: number,
315
+
316
+
317
+ properties?: boolean,
318
+
319
+
320
+ pure_getters?: any,
321
+
322
+
323
+ pure_funcs?: string[],
324
+
325
+
326
+ reduce_funcs?: boolean,
327
+
328
+
329
+ reduce_vars?: boolean,
330
+
331
+
332
+ sequences?: any,
333
+
334
+
335
+ side_effects?: boolean,
336
+
337
+
338
+ switches?: boolean,
339
+
340
+
341
+ top_retain?: any,
342
+
343
+
344
+ toplevel?: any,
345
+
346
+
347
+ typeofs?: boolean,
348
+
349
+
350
+ unsafe?: boolean,
351
+
352
+
353
+ unsafe_passes?: boolean,
354
+
355
+
356
+ unsafe_arrows?: boolean,
357
+
358
+
359
+ unsafe_comps?: boolean,
360
+
361
+
362
+ unsafe_function?: boolean,
363
+
364
+
365
+ unsafe_math?: boolean,
366
+
367
+
368
+ unsafe_symbols?: boolean,
369
+
370
+
371
+ unsafe_methods?: boolean,
372
+
373
+
374
+ unsafe_proto?: boolean,
375
+
376
+
377
+ unsafe_regexp?: boolean,
378
+
379
+
380
+ unsafe_undefined?: boolean,
381
+
382
+
383
+ unused?: boolean,
384
+
385
+
386
+ module?: boolean,
387
+ }
388
+
389
+ export interface TerserMangleOptions {
390
+ props?: TerserManglePropertiesOptions,
391
+
392
+ top_level?: boolean,
393
+
394
+ keep_class_names?: boolean,
395
+
396
+ keep_fn_names?: boolean,
397
+
398
+ keep_private_props?: boolean,
399
+
400
+ ie8?: boolean,
401
+
402
+ safari10?: boolean,
403
+
404
+ reserved?: string[],
405
+ }
406
+
407
+ export interface TerserManglePropertiesOptions {
408
+
409
+ }
410
+
411
+
412
+ /**
413
+ * Programmatic options.
414
+ */
415
+ export interface Options extends Config {
416
+ /**
417
+ * If true, a file is parsed as a script instead of module.
418
+ */
419
+ script?: boolean;
420
+
421
+ /**
422
+ * The working directory that all paths in the programmatic
423
+ * options will be resolved relative to.
424
+ *
425
+ * Defaults to `process.cwd()`.
426
+ */
427
+ cwd?: string;
428
+ caller?: CallerOptions;
429
+ /** The filename associated with the code currently being compiled,
430
+ * if there is one. The filename is optional, but not all of Swc's
431
+ * functionality is available when the filename is unknown, because a
432
+ * subset of options rely on the filename for their functionality.
433
+ *
434
+ * The three primary cases users could run into are:
435
+ *
436
+ * - The filename is exposed to plugins. Some plugins may require the
437
+ * presence of the filename.
438
+ * - Options like "test", "exclude", and "ignore" require the filename
439
+ * for string/RegExp matching.
440
+ * - .swcrc files are loaded relative to the file being compiled.
441
+ * If this option is omitted, Swc will behave as if swcrc: false has been set.
442
+ */
443
+ filename?: string;
444
+
445
+ /**
446
+ * The initial path that will be processed based on the "rootMode" to
447
+ * determine the conceptual root folder for the current Swc project.
448
+ * This is used in two primary cases:
449
+ *
450
+ * - The base directory when checking for the default "configFile" value
451
+ * - The default value for "swcrcRoots".
452
+ *
453
+ * Defaults to `opts.cwd`
454
+ */
455
+ root?: string;
456
+
457
+ /**
458
+ * This option, combined with the "root" value, defines how Swc chooses
459
+ * its project root. The different modes define different ways that Swc
460
+ * can process the "root" value to get the final project root.
461
+ *
462
+ * "root" - Passes the "root" value through as unchanged.
463
+ * "upward" - Walks upward from the "root" directory, looking for a directory
464
+ * containing a swc.config.js file, and throws an error if a swc.config.js
465
+ * is not found.
466
+ * "upward-optional" - Walk upward from the "root" directory, looking for
467
+ * a directory containing a swc.config.js file, and falls back to "root"
468
+ * if a swc.config.js is not found.
469
+ *
470
+ *
471
+ * "root" is the default mode because it avoids the risk that Swc
472
+ * will accidentally load a swc.config.js that is entirely outside
473
+ * of the current project folder. If you use "upward-optional",
474
+ * be aware that it will walk up the directory structure all the
475
+ * way to the filesystem root, and it is always possible that someone
476
+ * will have a forgotten swc.config.js in their home directory,
477
+ * which could cause unexpected errors in your builds.
478
+ *
479
+ *
480
+ * Users with monorepo project structures that run builds/tests on a
481
+ * per-package basis may well want to use "upward" since monorepos
482
+ * often have a swc.config.js in the project root. Running Swc
483
+ * in a monorepo subdirectory without "upward", will cause Swc
484
+ * to skip loading any swc.config.js files in the project root,
485
+ * which can lead to unexpected errors and compilation failure.
486
+ */
487
+ rootMode?: "root" | "upward" | "upward-optional";
488
+
489
+ /**
490
+ * The current active environment used during configuration loading.
491
+ * This value is used as the key when resolving "env" configs,
492
+ * and is also available inside configuration functions, plugins,
493
+ * and presets, via the api.env() function.
494
+ *
495
+ * Defaults to `process.env.SWC_ENV || process.env.NODE_ENV || "development"`
496
+ */
497
+ envName?: string;
498
+
499
+ /**
500
+ * Defaults to searching for a default `.swcrc` file, but can
501
+ * be passed the path of any JS or JSON5 config file.
502
+ *
503
+ *
504
+ * NOTE: This option does not affect loading of .swcrc files,
505
+ * so while it may be tempting to do configFile: "./foo/.swcrc",
506
+ * it is not recommended. If the given .swcrc is loaded via the
507
+ * standard file-relative logic, you'll end up loading the same
508
+ * config file twice, merging it with itself. If you are linking
509
+ * a specific config file, it is recommended to stick with a
510
+ * naming scheme that is independent of the "swcrc" name.
511
+ *
512
+ * Defaults to `path.resolve(opts.root, ".swcrc")`
513
+ */
514
+ configFile?: string | boolean;
515
+
516
+ /**
517
+ * true will enable searching for configuration files relative to the "filename" provided to Swc.
518
+ *
519
+ * A swcrc value passed in the programmatic options will override one set within a configuration file.
520
+ *
521
+ * Note: .swcrc files are only loaded if the current "filename" is inside of
522
+ * a package that matches one of the "swcrcRoots" packages.
523
+ *
524
+ *
525
+ * Defaults to true as long as the filename option has been specified
526
+ */
527
+ swcrc?: boolean;
528
+
529
+ /**
530
+ * By default, Babel will only search for .babelrc files within the "root" package
531
+ * because otherwise Babel cannot know if a given .babelrc is meant to be loaded,
532
+ * or if it's "plugins" and "presets" have even been installed, since the file
533
+ * being compiled could be inside node_modules, or have been symlinked into the project.
534
+ *
535
+ *
536
+ * This option allows users to provide a list of other packages that should be
537
+ * considered "root" packages when considering whether to load .babelrc files.
538
+ *
539
+ *
540
+ * For example, a monorepo setup that wishes to allow individual packages
541
+ * to have their own configs might want to do
542
+ *
543
+ *
544
+ *
545
+ * Defaults to `opts.root`
546
+ */
547
+ swcrcRoots?: boolean | MatchPattern | MatchPattern[];
548
+
549
+ /**
550
+ * `true` will attempt to load an input sourcemap from the file itself, if it
551
+ * contains a //# sourceMappingURL=... comment. If no map is found, or the
552
+ * map fails to load and parse, it will be silently discarded.
553
+ *
554
+ * If an object is provided, it will be treated as the source map object itself.
555
+ *
556
+ * Defaults to `true`.
557
+ */
558
+ inputSourceMap?: boolean | string;
559
+
560
+ /**
561
+ * The name to use for the file inside the source map object.
562
+ *
563
+ * Defaults to `path.basename(opts.filenameRelative)` when available, or `"unknown"`.
564
+ */
565
+ sourceFileName?: string;
566
+
567
+ /**
568
+ * The sourceRoot fields to set in the generated source map, if one is desired.
569
+ */
570
+ sourceRoot?: string;
571
+
572
+ plugin?: Plugin;
573
+
574
+ isModule?: boolean | 'unknown';
575
+
576
+ /**
577
+ * Destination path. Note that this value is used only to fix source path
578
+ * of source map files and swc does not write output to this path.
579
+ */
580
+ outputPath?: string
581
+ }
582
+
583
+ export interface CallerOptions {
584
+ name: string;
585
+ [key: string]: any;
586
+ }
587
+
588
+ export type Swcrc = Config | Config[];
589
+
590
+ /**
591
+ * .swcrc
592
+ */
593
+ export interface Config {
594
+ /**
595
+ * Note: The type is string because it follows rust's regex syntax.
596
+ */
597
+ test?: string | string[];
598
+ /**
599
+ * Note: The type is string because it follows rust's regex syntax.
600
+ */
601
+ exclude?: string | string[];
602
+ env?: EnvConfig;
603
+ jsc?: JscConfig;
604
+ module?: ModuleConfig;
605
+ minify?: boolean;
606
+
607
+ /**
608
+ * - true to generate a sourcemap for the code and include it in the result object.
609
+ * - "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.
610
+ *
611
+ * `swc-cli` overloads some of these to also affect how maps are written to disk:
612
+ *
613
+ * - true will write the map to a .map file on disk
614
+ * - "inline" will write the file directly, so it will have a data: containing the map
615
+ * - Note: These options are bit weird, so it may make the most sense to just use true
616
+ * and handle the rest in your own code, depending on your use case.
617
+ */
618
+ sourceMaps?: boolean | "inline";
619
+
620
+ inlineSourcesContent?: boolean
621
+ }
622
+
623
+ /**
624
+ * Configuration ported from babel-preset-env
625
+ */
626
+ export interface EnvConfig {
627
+ mode?: "usage" | "entry";
628
+ debug?: boolean;
629
+ dynamicImport?: boolean;
630
+
631
+ loose?: boolean;
632
+
633
+ /// Skipped es features.
634
+ ///
635
+ /// e.g.)
636
+ /// - `core-js/modules/foo`
637
+ skip?: string[];
638
+
639
+ include?: string[];
640
+
641
+ exclude?: string[];
642
+
643
+ /**
644
+ * The version of the used core js.
645
+ *
646
+ */
647
+ coreJs?: string;
648
+
649
+ targets?: any;
650
+
651
+ path?: string;
652
+
653
+ shippedProposals?: boolean;
654
+
655
+ /**
656
+ * Enable all transforms
657
+ */
658
+ forceAllTransforms?: boolean;
659
+ }
660
+
661
+ export interface JscConfig {
662
+ loose?: boolean;
663
+
664
+ /**
665
+ * Defaults to EsParserConfig
666
+ */
667
+ parser?: ParserConfig;
668
+ transform?: TransformConfig;
669
+ /**
670
+ * Use `@swc/helpers` instead of inline helpers.
671
+ */
672
+ externalHelpers?: boolean;
673
+
674
+ /**
675
+ * Defaults to `es3` (which enabled **all** pass).
676
+ */
677
+ target?: JscTarget;
678
+
679
+ /**
680
+ * Keep class names.
681
+ */
682
+ keepClassNames?: boolean
683
+
684
+ experimental?: {
685
+ optimizeHygiene?: boolean,
686
+ keepImportAssertions?: boolean,
687
+ /**
688
+ * Specify the location where SWC stores its intermediate cache files.
689
+ * Currently only transform plugin uses this. If not specified, SWC will
690
+ * create `.swc` directories.
691
+ */
692
+ cacheRoot?: string;
693
+ /**
694
+ * List of custom transform plugins written in WebAssembly.
695
+ * First parameter of tuple indicates the name of the plugin - it can be either
696
+ * a name of the npm package can be resolved, or absolute path to .wasm binary.
697
+ *
698
+ * Second parameter of tuple is JSON based configuration for the plugin.
699
+ */
700
+ plugins?: Array<[string, Record<string, any>]>
701
+ },
702
+
703
+ baseUrl?: string
704
+
705
+ paths?: {
706
+ [from: string]: [string]
707
+ }
708
+
709
+ minify?: JsMinifyOptions;
710
+
711
+ preserveAllComments?: boolean;
712
+ }
713
+
714
+ export type JscTarget =
715
+ | "es3"
716
+ | "es5"
717
+ | "es2015"
718
+ | "es2016"
719
+ | "es2017"
720
+ | "es2018"
721
+ | "es2019"
722
+ | "es2020"
723
+ | "es2021"
724
+ | "es2022";
725
+
726
+ export type ParserConfig = TsParserConfig | EsParserConfig;
727
+ export interface TsParserConfig {
728
+ syntax: "typescript";
729
+ /**
730
+ * Defaults to `false`.
731
+ */
732
+ tsx?: boolean;
733
+ /**
734
+ * Defaults to `false`.
735
+ */
736
+ decorators?: boolean;
737
+ /**
738
+ * Defaults to `false`
739
+ */
740
+ dynamicImport?: boolean;
741
+ }
742
+
743
+ export interface EsParserConfig {
744
+ syntax: "ecmascript";
745
+ /**
746
+ * Defaults to false.
747
+ */
748
+ jsx?: boolean;
749
+ /**
750
+ * @deprecated Always true because it's in ecmascript spec.
751
+ */
752
+ numericSeparator?: boolean;
753
+ /**
754
+ * @deprecated Always true because it's in ecmascript spec.
755
+ */
756
+ classPrivateProperty?: boolean;
757
+ /**
758
+ * @deprecated Always true because it's in ecmascript spec.
759
+ */
760
+ privateMethod?: boolean;
761
+ /**
762
+ * @deprecated Always true because it's in ecmascript spec.
763
+ */
764
+ classProperty?: boolean;
765
+ /**
766
+ * Defaults to `false`
767
+ */
768
+ functionBind?: boolean;
769
+ /**
770
+ * Defaults to `false`
771
+ */
772
+ decorators?: boolean;
773
+ /**
774
+ * Defaults to `false`
775
+ */
776
+ decoratorsBeforeExport?: boolean;
777
+ /**
778
+ * Defaults to `false`
779
+ */
780
+ exportDefaultFrom?: boolean;
781
+ /**
782
+ * @deprecated Always true because it's in ecmascript spec.
783
+ */
784
+ exportNamespaceFrom?: boolean;
785
+ /**
786
+ * @deprecated Always true because it's in ecmascript spec.
787
+ */
788
+ dynamicImport?: boolean;
789
+ /**
790
+ * @deprecated Always true because it's in ecmascript spec.
791
+ */
792
+ nullishCoalescing?: boolean;
793
+ /**
794
+ * @deprecated Always true because it's in ecmascript spec.
795
+ */
796
+ optionalChaining?: boolean;
797
+ /**
798
+ * @deprecated Always true because it's in ecmascript spec.
799
+ */
800
+ importMeta?: boolean;
801
+ /**
802
+ * @deprecated Always true because it's in ecmascript spec.
803
+ */
804
+ topLevelAwait?: boolean;
805
+ /**
806
+ * Defaults to `false`
807
+ */
808
+ importAssertions?: boolean;
809
+ }
810
+
811
+ /**
812
+ * Options for transform.
813
+ */
814
+ export interface TransformConfig {
815
+ /**
816
+ * Effective only if `syntax` supports ƒ.
817
+ */
818
+ react?: ReactConfig;
819
+
820
+ constModules?: ConstModulesConfig;
821
+
822
+ /**
823
+ * Defaults to null, which skips optimizer pass.
824
+ */
825
+ optimizer?: OptimizerConfig;
826
+
827
+ /**
828
+ * https://swc.rs/docs/configuring-swc.html#jsctransformlegacydecorator
829
+ */
830
+ legacyDecorator?: boolean;
831
+
832
+ /**
833
+ * https://swc.rs/docs/configuring-swc.html#jsctransformdecoratormetadata
834
+ */
835
+ decoratorMetadata?: boolean;
836
+
837
+ treatConstEnumAsEnum?: boolean;
838
+
839
+ useDefineForClassFields?: boolean;
840
+ }
841
+
842
+ export interface ReactConfig {
843
+ /**
844
+ * Replace the function used when compiling JSX expressions.
845
+ *
846
+ * Defaults to `React.createElement`.
847
+ */
848
+ pragma?: string;
849
+ /**
850
+ * Replace the component used when compiling JSX fragments.
851
+ *
852
+ * Defaults to `React.Fragment`
853
+ */
854
+ pragmaFrag?: string;
855
+ /**
856
+ * Toggles whether or not to throw an error if a XML namespaced tag name is used. For example:
857
+ * `<f:image />`
858
+ *
859
+ * Though the JSX spec allows this, it is disabled by default since React's
860
+ * JSX does not currently have support for it.
861
+ *
862
+ */
863
+ throwIfNamespace?: boolean;
864
+ /**
865
+ * Toggles plugins that aid in development, such as @swc/plugin-transform-react-jsx-self
866
+ * and @swc/plugin-transform-react-jsx-source.
867
+ *
868
+ * Defaults to `false`,
869
+ *
870
+ */
871
+ development?: boolean;
872
+ /**
873
+ * Use `Object.assign()` instead of `_extends`. Defaults to false.
874
+ */
875
+ useBuiltins?: boolean;
876
+
877
+ /**
878
+ * Enable fast refresh feature for React app
879
+ */
880
+ refresh?: boolean;
881
+
882
+ /**
883
+ * jsx runtime
884
+ */
885
+ runtime?: 'automatic' | 'classic'
886
+
887
+ /**
888
+ * Declares the module specifier to be used for importing the `jsx` and `jsxs` factory functions when using `runtime` 'automatic'
889
+ */
890
+ importSource?: string
891
+ }
892
+ /**
893
+ * - `import { DEBUG } from '@ember/env-flags';`
894
+ * - `import { FEATURE_A, FEATURE_B } from '@ember/features';`
895
+ *
896
+ * See: https://github.com/swc-project/swc/issues/18#issuecomment-466272558
897
+ */
898
+ export interface ConstModulesConfig {
899
+ globals?: {
900
+ [module: string]: {
901
+ [name: string]: string;
902
+ };
903
+ };
904
+ }
905
+
906
+ /// https://swc.rs/docs/configuring-swc.html#jsctransformoptimizerjsonify
907
+ export interface OptimizerConfig {
908
+ /// https://swc.rs/docs/configuration/compilation#jsctransformoptimizersimplify
909
+ simplify?: boolean;
910
+ /// https://swc.rs/docs/configuring-swc.html#jsctransformoptimizerglobals
911
+ globals?: GlobalPassOption;
912
+ /// https://swc.rs/docs/configuring-swc.html#jsctransformoptimizerjsonify
913
+ jsonify?: { minCost: number };
914
+ }
915
+
916
+ /**
917
+ * Options for inline-global pass.
918
+ */
919
+ export interface GlobalPassOption {
920
+ /**
921
+ * Global variables.
922
+ *
923
+ * e.g. `{ __DEBUG__: true }`
924
+ */
925
+ vars?: { [key: string]: string };
926
+
927
+ /**
928
+ * Name of environment variables to inline.
929
+ *
930
+ * Defaults to `["NODE_ENV", "SWC_ENV"]`
931
+ */
932
+ envs?: string[];
933
+ }
934
+
935
+ export type ModuleConfig = Es6Config | CommonJsConfig | UmdConfig | AmdConfig | NodeNextConfig;
936
+
937
+ export interface BaseModuleConfig {
938
+ /**
939
+ * By default, when using exports with babel a non-enumerable `__esModule`
940
+ * property is exported. In some cases this property is used to determine
941
+ * if the import is the default export or if it contains the default export.
942
+ *
943
+ * In order to prevent the __esModule property from being exported, you
944
+ * can set the strict option to true.
945
+ *
946
+ * Defaults to `false`.
947
+ */
948
+ strict?: boolean;
949
+
950
+ /**
951
+ * Emits 'use strict' directive.
952
+ *
953
+ * Defaults to `true`.
954
+ */
955
+ strictMode?: boolean;
956
+
957
+ /**
958
+ * Changes Babel's compiled import statements to be lazily evaluated when their imported bindings are used for the first time.
959
+ *
960
+ * This can improve initial load time of your module because evaluating dependencies up
961
+ * front is sometimes entirely un-necessary. This is especially the case when implementing
962
+ * a library module.
963
+ *
964
+ *
965
+ * The value of `lazy` has a few possible effects:
966
+ *
967
+ * - `false` - No lazy initialization of any imported module.
968
+ * - `true` - Do not lazy-initialize local `./foo` imports, but lazy-init `foo` dependencies.
969
+ *
970
+ * Local paths are much more likely to have circular dependencies, which may break if loaded lazily,
971
+ * so they are not lazy by default, whereas dependencies between independent modules are rarely cyclical.
972
+ *
973
+ * - `Array<string>` - Lazy-initialize all imports with source matching one of the given strings.
974
+ *
975
+ * -----
976
+ *
977
+ * The two cases where imports can never be lazy are:
978
+ *
979
+ * - `import "foo";`
980
+ *
981
+ * Side-effect imports are automatically non-lazy since their very existence means
982
+ * that there is no binding to later kick off initialization.
983
+ *
984
+ * - `export * from "foo"`
985
+ *
986
+ * Re-exporting all names requires up-front execution because otherwise there is no
987
+ * way to know what names need to be exported.
988
+ *
989
+ * Defaults to `false`.
990
+ */
991
+ lazy?: boolean | string[];
992
+ /**
993
+ * @deprecated Use the `importInterop` option instead.
994
+ *
995
+ * By default, when using exports with swc a non-enumerable __esModule property is exported.
996
+ * This property is then used to determine if the import is the default export or if
997
+ * it contains the default export.
998
+ *
999
+ * In cases where the auto-unwrapping of default is not needed, you can set the noInterop option
1000
+ * to true to avoid the usage of the interopRequireDefault helper (shown in inline form above).
1001
+ *
1002
+ * Defaults to `false`.
1003
+ */
1004
+ noInterop?: boolean;
1005
+ /**
1006
+ * Defaults to `swc`.
1007
+ *
1008
+ * CommonJS modules and ECMAScript modules are not fully compatible.
1009
+ * However, compilers, bundlers and JavaScript runtimes developed different strategies
1010
+ * to make them work together as well as possible.
1011
+ *
1012
+ * - `swc` (alias: `babel`)
1013
+ *
1014
+ * When using exports with `swc` a non-enumerable `__esModule` property is exported
1015
+ * This property is then used to determine if the import is the default export
1016
+ * or if it contains the default export.
1017
+ *
1018
+ * ```javascript
1019
+ * import foo from "foo";
1020
+ * import { bar } from "bar";
1021
+ * foo;
1022
+ * bar;
1023
+ *
1024
+ * // Is compiled to ...
1025
+ *
1026
+ * "use strict";
1027
+ *
1028
+ * function _interopRequireDefault(obj) {
1029
+ * return obj && obj.__esModule ? obj : { default: obj };
1030
+ * }
1031
+ *
1032
+ * var _foo = _interopRequireDefault(require("foo"));
1033
+ * var _bar = require("bar");
1034
+ *
1035
+ * _foo.default;
1036
+ * _bar.bar;
1037
+ * ```
1038
+ *
1039
+ * When this import interop is used, if both the imported and the importer module are compiled
1040
+ * with swc they behave as if none of them was compiled.
1041
+ *
1042
+ * This is the default behavior.
1043
+ *
1044
+ * - `node`
1045
+ *
1046
+ * When importing CommonJS files (either directly written in CommonJS, or generated with a compiler)
1047
+ * Node.js always binds the `default` export to the value of `module.exports`.
1048
+ *
1049
+ * ```javascript
1050
+ * import foo from "foo";
1051
+ * import { bar } from "bar";
1052
+ * foo;
1053
+ * bar;
1054
+ *
1055
+ * // Is compiled to ...
1056
+ *
1057
+ * "use strict";
1058
+ *
1059
+ * var _foo = require("foo");
1060
+ * var _bar = require("bar");
1061
+ *
1062
+ * _foo;
1063
+ * _bar.bar;
1064
+ * ```
1065
+ * This is not exactly the same as what Node.js does since swc allows accessing any property of `module.exports`
1066
+ * as a named export, while Node.js only allows importing statically analyzable properties of `module.exports`.
1067
+ * However, any import working in Node.js will also work when compiled with swc using `importInterop: "node"`.
1068
+ *
1069
+ * - `none`
1070
+ *
1071
+ * If you know that the imported file has been transformed with a compiler that stores the `default` export on
1072
+ * `exports.default` (such as swc or Babel), you can safely omit the `_interopRequireDefault` helper.
1073
+ *
1074
+ * ```javascript
1075
+ * import foo from "foo";
1076
+ * import { bar } from "bar";
1077
+ * foo;
1078
+ * bar;
1079
+ *
1080
+ * // Is compiled to ...
1081
+ *
1082
+ * "use strict";
1083
+ *
1084
+ * var _foo = require("foo");
1085
+ * var _bar = require("bar");
1086
+ *
1087
+ * _foo.default;
1088
+ * _bar.bar;
1089
+ * ```
1090
+ */
1091
+ importInterop?: "swc" | "babel" | "node" | "none";
1092
+ /**
1093
+ * If set to true, dynamic imports will be preserved.
1094
+ */
1095
+ ignoreDynamic?: boolean;
1096
+ }
1097
+
1098
+ export interface Es6Config extends BaseModuleConfig {
1099
+ type: "es6";
1100
+ }
1101
+
1102
+ export interface NodeNextConfig extends BaseModuleConfig {
1103
+ type: "nodenext";
1104
+ }
1105
+
1106
+ export interface CommonJsConfig extends BaseModuleConfig {
1107
+ type: "commonjs";
1108
+ }
1109
+
1110
+ export interface UmdConfig extends BaseModuleConfig {
1111
+ type: "umd";
1112
+ globals?: { [key: string]: string };
1113
+ }
1114
+
1115
+ export interface AmdConfig extends BaseModuleConfig {
1116
+ type: "amd";
1117
+ moduleId?: string;
1118
+ }
1119
+
1120
+ export interface Output {
1121
+ /**
1122
+ * Transformed code
1123
+ */
1124
+ code: string;
1125
+ /**
1126
+ * Sourcemap (**not** base64 encoded)
1127
+ */
1128
+ map?: string;
1129
+ }
1130
+
1131
+ export interface MatchPattern { }
1132
+
1133
+ // -------------------------------
1134
+ // ---------- Ast nodes ----------
1135
+ // -------------------------------
1136
+
1137
+ export interface Span {
1138
+ start: number;
1139
+ end: number;
1140
+ ctxt: number;
1141
+ }
1142
+
1143
+ export interface Node {
1144
+ type: string;
1145
+ }
1146
+
1147
+ export interface HasSpan {
1148
+ span: Span;
1149
+ }
1150
+
1151
+ export interface HasDecorator {
1152
+ decorators?: Decorator[];
1153
+ }
1154
+
1155
+ export interface Class extends HasSpan, HasDecorator {
1156
+ body: ClassMember[];
1157
+
1158
+ superClass?: Expression;
1159
+
1160
+ isAbstract: boolean;
1161
+
1162
+ typeParams?: TsTypeParameterDeclaration;
1163
+
1164
+ superTypeParams?: TsTypeParameterInstantiation;
1165
+
1166
+ implements: TsExpressionWithTypeArguments[];
1167
+ }
1168
+
1169
+ export type ClassMember =
1170
+ | Constructor
1171
+ | ClassMethod
1172
+ | PrivateMethod
1173
+ | ClassProperty
1174
+ | PrivateProperty
1175
+ | TsIndexSignature
1176
+ | EmptyStatement
1177
+ | StaticBlock;
1178
+
1179
+ export interface ClassPropertyBase extends Node, HasSpan, HasDecorator {
1180
+ value?: Expression;
1181
+
1182
+ typeAnnotation?: TsTypeAnnotation;
1183
+
1184
+ isStatic: boolean;
1185
+
1186
+ accessibility?: Accessibility;
1187
+
1188
+ isOptional: boolean;
1189
+
1190
+ isOverride: boolean;
1191
+
1192
+ readonly: boolean;
1193
+
1194
+ definite: boolean;
1195
+ }
1196
+
1197
+ export interface ClassProperty extends ClassPropertyBase {
1198
+ type: "ClassProperty";
1199
+
1200
+ key: PropertyName;
1201
+
1202
+ isAbstract: boolean;
1203
+
1204
+ declare: boolean;
1205
+ }
1206
+
1207
+ export interface PrivateProperty extends ClassPropertyBase {
1208
+ type: "PrivateProperty";
1209
+
1210
+ key: PrivateName;
1211
+ }
1212
+
1213
+ export interface Param extends Node, HasSpan, HasDecorator {
1214
+ type: "Parameter";
1215
+ pat: Pattern;
1216
+ }
1217
+
1218
+ export interface Constructor extends Node, HasSpan {
1219
+ type: "Constructor";
1220
+
1221
+ key: PropertyName;
1222
+
1223
+ params: (TsParameterProperty | Param)[];
1224
+
1225
+ body?: BlockStatement;
1226
+
1227
+ accessibility?: Accessibility;
1228
+
1229
+ isOptional: boolean;
1230
+ }
1231
+
1232
+ export interface ClassMethodBase extends Node, HasSpan {
1233
+ function: Fn;
1234
+
1235
+ kind: MethodKind;
1236
+
1237
+ isStatic: boolean;
1238
+
1239
+ accessibility?: Accessibility;
1240
+
1241
+ isAbstract: boolean;
1242
+
1243
+ isOptional: boolean;
1244
+
1245
+ isOverride: boolean;
1246
+ }
1247
+
1248
+ export interface ClassMethod extends ClassMethodBase {
1249
+ type: "ClassMethod";
1250
+
1251
+ key: PropertyName;
1252
+ }
1253
+
1254
+ export interface PrivateMethod extends ClassMethodBase {
1255
+ type: "PrivateMethod";
1256
+
1257
+ key: PrivateName;
1258
+ }
1259
+
1260
+ export interface StaticBlock extends Node, HasSpan {
1261
+ type: "StaticBlock";
1262
+
1263
+ body: BlockStatement;
1264
+ }
1265
+
1266
+ export interface Decorator extends Node, HasSpan {
1267
+ type: "Decorator";
1268
+
1269
+ expression: Expression;
1270
+ }
1271
+
1272
+ export type MethodKind = "method" | "getter" | "setter";
1273
+
1274
+ export type Declaration =
1275
+ | ClassDeclaration
1276
+ | FunctionDeclaration
1277
+ | VariableDeclaration
1278
+ | TsInterfaceDeclaration
1279
+ | TsTypeAliasDeclaration
1280
+ | TsEnumDeclaration
1281
+ | TsModuleDeclaration;
1282
+
1283
+ export interface FunctionDeclaration extends Fn {
1284
+ type: "FunctionDeclaration";
1285
+
1286
+ identifier: Identifier;
1287
+
1288
+ declare: boolean;
1289
+ }
1290
+
1291
+ export interface ClassDeclaration extends Class, Node {
1292
+ type: "ClassDeclaration";
1293
+
1294
+ identifier: Identifier;
1295
+
1296
+ declare: boolean;
1297
+ }
1298
+
1299
+ export interface VariableDeclaration extends Node, HasSpan {
1300
+ type: "VariableDeclaration";
1301
+
1302
+ kind: VariableDeclarationKind;
1303
+
1304
+ declare: boolean;
1305
+
1306
+ declarations: VariableDeclarator[];
1307
+ }
1308
+
1309
+ export type VariableDeclarationKind = "var" | "let" | "const";
1310
+
1311
+ export interface VariableDeclarator extends Node, HasSpan {
1312
+ type: "VariableDeclarator";
1313
+
1314
+ id: Pattern;
1315
+
1316
+ /// Initialization expression.
1317
+ init?: Expression;
1318
+
1319
+ /// Typescript only
1320
+ definite: boolean;
1321
+ }
1322
+
1323
+ export type Expression =
1324
+ | ThisExpression
1325
+ | ArrayExpression
1326
+ | ObjectExpression
1327
+ | FunctionExpression
1328
+ | UnaryExpression
1329
+ | UpdateExpression
1330
+ | BinaryExpression
1331
+ | AssignmentExpression
1332
+ | MemberExpression
1333
+ | SuperPropExpression
1334
+ | ConditionalExpression
1335
+ | CallExpression
1336
+ | NewExpression
1337
+ | SequenceExpression
1338
+ | Identifier
1339
+ | Literal
1340
+ | TemplateLiteral
1341
+ | TaggedTemplateExpression
1342
+ | ArrowFunctionExpression
1343
+ | ClassExpression
1344
+ | YieldExpression
1345
+ | MetaProperty
1346
+ | AwaitExpression
1347
+ | ParenthesisExpression
1348
+ | JSXMemberExpression
1349
+ | JSXNamespacedName
1350
+ | JSXEmptyExpression
1351
+ | JSXElement
1352
+ | JSXFragment
1353
+ | TsTypeAssertion
1354
+ | TsConstAssertion
1355
+ | TsNonNullExpression
1356
+ | TsAsExpression
1357
+ | TsInstantiation
1358
+ | PrivateName
1359
+ | OptionalChainingExpression
1360
+ | Invalid;
1361
+
1362
+ interface ExpressionBase extends Node, HasSpan { }
1363
+
1364
+ export interface Identifier extends ExpressionBase {
1365
+ type: "Identifier";
1366
+
1367
+ value: string;
1368
+
1369
+ /// TypeScript only. Used in case of an optional parameter.
1370
+ optional: boolean;
1371
+ }
1372
+
1373
+ export interface OptionalChainingExpression extends ExpressionBase {
1374
+ type: "OptionalChainingExpression";
1375
+ questionDotToken: Span;
1376
+ /**
1377
+ * Call expression or member expression.
1378
+ */
1379
+ base: MemberExpression | OptionalChainingCall;
1380
+ }
1381
+
1382
+ export interface OptionalChainingCall extends ExpressionBase {
1383
+ type: "CallExpression";
1384
+ callee: Expression;
1385
+ arguments: ExprOrSpread[];
1386
+ typeArguments?: TsTypeParameterInstantiation;
1387
+ }
1388
+
1389
+ export interface ThisExpression extends ExpressionBase {
1390
+ type: "ThisExpression";
1391
+ }
1392
+
1393
+ export interface ArrayExpression extends ExpressionBase {
1394
+ type: "ArrayExpression";
1395
+
1396
+ elements: (ExprOrSpread | undefined)[];
1397
+ }
1398
+
1399
+ export interface ExprOrSpread {
1400
+ spread?: Span;
1401
+ expression: Expression;
1402
+ }
1403
+
1404
+ export interface ObjectExpression extends ExpressionBase {
1405
+ type: "ObjectExpression";
1406
+
1407
+ properties: (SpreadElement | Property)[];
1408
+ }
1409
+
1410
+ export interface Argument {
1411
+ spread?: Span;
1412
+ expression: Expression;
1413
+ }
1414
+
1415
+ export interface SpreadElement extends Node {
1416
+ type: "SpreadElement";
1417
+
1418
+ spread: Span;
1419
+
1420
+ arguments: Expression;
1421
+ }
1422
+
1423
+ export interface UnaryExpression extends ExpressionBase {
1424
+ type: "UnaryExpression";
1425
+
1426
+ operator: UnaryOperator;
1427
+
1428
+ argument: Expression;
1429
+ }
1430
+
1431
+ export interface UpdateExpression extends ExpressionBase {
1432
+ type: "UpdateExpression";
1433
+
1434
+ operator: UpdateOperator;
1435
+
1436
+ prefix: boolean;
1437
+
1438
+ argument: Expression;
1439
+ }
1440
+
1441
+ export interface BinaryExpression extends ExpressionBase {
1442
+ type: "BinaryExpression";
1443
+
1444
+ operator: BinaryOperator;
1445
+
1446
+ left: Expression;
1447
+
1448
+ right: Expression;
1449
+ }
1450
+
1451
+ export interface FunctionExpression extends Fn, ExpressionBase {
1452
+ type: "FunctionExpression";
1453
+
1454
+ identifier?: Identifier;
1455
+ }
1456
+
1457
+ export interface ClassExpression extends Class, ExpressionBase {
1458
+ type: "ClassExpression";
1459
+
1460
+ identifier?: Identifier;
1461
+ }
1462
+
1463
+ export interface AssignmentExpression extends ExpressionBase {
1464
+ type: "AssignmentExpression";
1465
+
1466
+ operator: AssignmentOperator;
1467
+
1468
+ left: Expression | Pattern;
1469
+
1470
+ right: Expression;
1471
+ }
1472
+
1473
+ export interface MemberExpression extends ExpressionBase {
1474
+ type: "MemberExpression";
1475
+
1476
+ object: Expression;
1477
+
1478
+ property: Identifier | PrivateName | ComputedPropName;
1479
+ }
1480
+
1481
+ export interface SuperPropExpression extends ExpressionBase {
1482
+ type: "SuperPropExpression";
1483
+
1484
+ obj: Super;
1485
+
1486
+ property: Identifier | ComputedPropName;
1487
+ }
1488
+
1489
+ export interface ConditionalExpression extends ExpressionBase {
1490
+ type: "ConditionalExpression";
1491
+
1492
+ test: Expression;
1493
+
1494
+ consequent: Expression;
1495
+
1496
+ alternate: Expression;
1497
+ }
1498
+
1499
+ export interface Super extends Node, HasSpan {
1500
+ type: "Super";
1501
+ }
1502
+
1503
+ export interface Import extends Node, HasSpan {
1504
+ type: "Import";
1505
+ }
1506
+
1507
+ export interface CallExpression extends ExpressionBase {
1508
+ type: "CallExpression";
1509
+
1510
+ callee: Super | Import | Expression;
1511
+
1512
+ arguments: Argument[];
1513
+
1514
+ typeArguments?: TsTypeParameterInstantiation;
1515
+ }
1516
+
1517
+ export interface NewExpression extends ExpressionBase {
1518
+ type: "NewExpression";
1519
+
1520
+ callee: Expression;
1521
+
1522
+ arguments?: Argument[];
1523
+
1524
+ typeArguments?: TsTypeParameterInstantiation;
1525
+ }
1526
+
1527
+ export interface SequenceExpression extends ExpressionBase {
1528
+ type: "SequenceExpression";
1529
+
1530
+ expressions: Expression[];
1531
+ }
1532
+
1533
+ export interface ArrowFunctionExpression extends ExpressionBase {
1534
+ type: "ArrowFunctionExpression";
1535
+
1536
+ params: Pattern[];
1537
+
1538
+ body: BlockStatement | Expression;
1539
+
1540
+ async: boolean;
1541
+
1542
+ generator: boolean;
1543
+
1544
+ typeParameters?: TsTypeParameterDeclaration;
1545
+
1546
+ returnType?: TsTypeAnnotation;
1547
+ }
1548
+
1549
+ export interface YieldExpression extends ExpressionBase {
1550
+ type: "YieldExpression";
1551
+
1552
+ argument?: Expression;
1553
+
1554
+ delegate: boolean;
1555
+ }
1556
+
1557
+ export interface MetaProperty extends Node, HasSpan {
1558
+ type: "MetaProperty";
1559
+
1560
+ kind: "new.target" | "import.meta";
1561
+ }
1562
+
1563
+ export interface AwaitExpression extends ExpressionBase {
1564
+ type: "AwaitExpression";
1565
+
1566
+ argument: Expression;
1567
+ }
1568
+
1569
+ export interface TemplateLiteral extends ExpressionBase {
1570
+ type: "TemplateLiteral";
1571
+
1572
+ expressions: Expression[];
1573
+
1574
+ quasis: TemplateElement[];
1575
+ }
1576
+
1577
+ export interface TaggedTemplateExpression extends ExpressionBase {
1578
+ type: "TaggedTemplateExpression";
1579
+
1580
+ tag: Expression;
1581
+
1582
+ typeParameters?: TsTypeParameterInstantiation;
1583
+
1584
+ template: TemplateLiteral;
1585
+ }
1586
+
1587
+ export interface TemplateElement extends ExpressionBase {
1588
+ type: "TemplateElement";
1589
+
1590
+ tail: boolean;
1591
+ cooked?: string;
1592
+ raw: string;
1593
+ }
1594
+
1595
+ export interface ParenthesisExpression extends ExpressionBase {
1596
+ type: "ParenthesisExpression";
1597
+
1598
+ expression: Expression;
1599
+ }
1600
+
1601
+ export interface Fn extends HasSpan, HasDecorator {
1602
+ params: Param[];
1603
+
1604
+ body?: BlockStatement;
1605
+
1606
+ generator: boolean;
1607
+
1608
+ async: boolean;
1609
+
1610
+ typeParameters?: TsTypeParameterDeclaration;
1611
+
1612
+ returnType?: TsTypeAnnotation;
1613
+ }
1614
+
1615
+ interface PatternBase extends Node, HasSpan {
1616
+ typeAnnotation?: TsTypeAnnotation;
1617
+ }
1618
+
1619
+ export interface PrivateName extends ExpressionBase {
1620
+ type: "PrivateName";
1621
+
1622
+ id: Identifier;
1623
+ }
1624
+
1625
+ export type JSXObject = JSXMemberExpression | Identifier;
1626
+
1627
+ export interface JSXMemberExpression extends Node {
1628
+ type: "JSXMemberExpression";
1629
+
1630
+ object: JSXObject;
1631
+ property: Identifier;
1632
+ }
1633
+
1634
+ /**
1635
+ * XML-based namespace syntax:
1636
+ */
1637
+ export interface JSXNamespacedName extends Node {
1638
+ type: "JSXNamespacedName";
1639
+
1640
+ namespace: Identifier;
1641
+ name: Identifier;
1642
+ }
1643
+
1644
+ export interface JSXEmptyExpression extends Node, HasSpan {
1645
+ type: "JSXEmptyExpression";
1646
+ }
1647
+
1648
+ export interface JSXExpressionContainer extends Node, HasSpan {
1649
+ type: "JSXExpressionContainer";
1650
+
1651
+ expression: JSXExpression;
1652
+ }
1653
+
1654
+ export type JSXExpression = JSXEmptyExpression | Expression;
1655
+
1656
+ export interface JSXSpreadChild extends Node, HasSpan {
1657
+ type: "JSXSpreadChild";
1658
+
1659
+ expression: Expression;
1660
+ }
1661
+
1662
+ export type JSXElementName =
1663
+ | Identifier
1664
+ | JSXMemberExpression
1665
+ | JSXNamespacedName;
1666
+
1667
+ export interface JSXOpeningElement extends Node, HasSpan {
1668
+ type: "JSXOpeningElement";
1669
+
1670
+ name: JSXElementName;
1671
+
1672
+ attributes: JSXAttributeOrSpread[];
1673
+
1674
+ selfClosing: boolean;
1675
+
1676
+ typeArguments?: TsTypeParameterInstantiation;
1677
+ }
1678
+
1679
+ export type JSXAttributeOrSpread = JSXAttribute | SpreadElement;
1680
+
1681
+ export interface JSXClosingElement extends Node, HasSpan {
1682
+ type: "JSXClosingElement";
1683
+
1684
+ name: JSXElementName;
1685
+ }
1686
+
1687
+ export interface JSXAttribute extends Node, HasSpan {
1688
+ type: "JSXAttribute";
1689
+
1690
+ name: JSXAttributeName;
1691
+
1692
+ value?: JSXAttrValue;
1693
+ }
1694
+
1695
+ export type JSXAttributeName = Identifier | JSXNamespacedName;
1696
+
1697
+ export type JSXAttrValue =
1698
+ | Literal
1699
+ | JSXExpressionContainer
1700
+ | JSXElement
1701
+ | JSXFragment;
1702
+
1703
+ export interface JSXText extends Node, HasSpan {
1704
+ type: "JSXText";
1705
+
1706
+ value: string;
1707
+ raw: string;
1708
+ }
1709
+
1710
+ export interface JSXElement extends Node, HasSpan {
1711
+ type: "JSXElement";
1712
+
1713
+ opening: JSXOpeningElement;
1714
+ children: JSXElementChild[];
1715
+ closing?: JSXClosingElement;
1716
+ }
1717
+
1718
+ export type JSXElementChild =
1719
+ | JSXText
1720
+ | JSXExpressionContainer
1721
+ | JSXSpreadChild
1722
+ | JSXElement
1723
+ | JSXFragment;
1724
+
1725
+ export interface JSXFragment extends Node, HasSpan {
1726
+ type: "JSXFragment";
1727
+
1728
+ opening: JSXOpeningFragment;
1729
+
1730
+ children: JSXElementChild[];
1731
+
1732
+ closing: JSXClosingFragment;
1733
+ }
1734
+
1735
+ export interface JSXOpeningFragment extends Node, HasSpan {
1736
+ type: "JSXOpeningFragment";
1737
+ }
1738
+
1739
+ export interface JSXClosingFragment extends Node, HasSpan {
1740
+ type: "JSXClosingFragment";
1741
+ }
1742
+
1743
+ export type Literal =
1744
+ | StringLiteral
1745
+ | BooleanLiteral
1746
+ | NullLiteral
1747
+ | NumericLiteral
1748
+ | BigIntLiteral
1749
+ | RegExpLiteral
1750
+ | JSXText;
1751
+
1752
+ export interface StringLiteral extends Node, HasSpan {
1753
+ type: "StringLiteral";
1754
+
1755
+ value: string;
1756
+
1757
+ raw?: string;
1758
+ }
1759
+
1760
+ export interface BooleanLiteral extends Node, HasSpan {
1761
+ type: "BooleanLiteral";
1762
+
1763
+ value: boolean;
1764
+ }
1765
+
1766
+ export interface NullLiteral extends Node, HasSpan {
1767
+ type: "NullLiteral";
1768
+ }
1769
+
1770
+ export interface RegExpLiteral extends Node, HasSpan {
1771
+ type: "RegExpLiteral";
1772
+
1773
+ pattern: string;
1774
+ flags: string;
1775
+ }
1776
+
1777
+ export interface NumericLiteral extends Node, HasSpan {
1778
+ type: "NumericLiteral";
1779
+
1780
+ value: number;
1781
+
1782
+ raw?: string;
1783
+ }
1784
+
1785
+ export interface BigIntLiteral extends Node, HasSpan {
1786
+ type: "BigIntLiteral";
1787
+
1788
+ value: bigint;
1789
+
1790
+ raw?: string;
1791
+ }
1792
+
1793
+ export type ModuleDeclaration =
1794
+ | ImportDeclaration
1795
+ | ExportDeclaration
1796
+ | ExportNamedDeclaration
1797
+ | ExportDefaultDeclaration
1798
+ | ExportDefaultExpression
1799
+ | ExportAllDeclaration
1800
+ | TsImportEqualsDeclaration
1801
+ | TsExportAssignment
1802
+ | TsNamespaceExportDeclaration;
1803
+
1804
+ export interface ExportDefaultExpression extends Node, HasSpan {
1805
+ type: "ExportDefaultExpression";
1806
+
1807
+ expression: Expression;
1808
+ }
1809
+
1810
+ export interface ExportDeclaration extends Node, HasSpan {
1811
+ type: "ExportDeclaration";
1812
+
1813
+ declaration: Declaration;
1814
+ }
1815
+
1816
+ export interface ImportDeclaration extends Node, HasSpan {
1817
+ type: "ImportDeclaration";
1818
+
1819
+ specifiers: ImportSpecifier[];
1820
+
1821
+ source: StringLiteral;
1822
+
1823
+ typeOnly: boolean;
1824
+
1825
+ asserts?: ObjectExpression;
1826
+ }
1827
+
1828
+ export interface ExportAllDeclaration extends Node, HasSpan {
1829
+ type: "ExportAllDeclaration";
1830
+
1831
+ source: StringLiteral;
1832
+
1833
+ asserts?: ObjectExpression;
1834
+ }
1835
+
1836
+ /**
1837
+ * - `export { foo } from 'mod'`
1838
+ * - `export { foo as bar } from 'mod'`
1839
+ */
1840
+ export interface ExportNamedDeclaration extends Node, HasSpan {
1841
+ type: "ExportNamedDeclaration";
1842
+
1843
+ specifiers: ExportSpecifier[];
1844
+
1845
+ source?: StringLiteral;
1846
+
1847
+ typeOnly: boolean;
1848
+
1849
+ asserts?: ObjectExpression;
1850
+ }
1851
+
1852
+ export interface ExportDefaultDeclaration extends Node, HasSpan {
1853
+ type: "ExportDefaultDeclaration";
1854
+
1855
+ decl: DefaultDecl;
1856
+ }
1857
+
1858
+ export type DefaultDecl =
1859
+ | ClassExpression
1860
+ | FunctionExpression
1861
+ | TsInterfaceDeclaration;
1862
+
1863
+ export type ImportSpecifier =
1864
+ | NamedImportSpecifier
1865
+ | ImportDefaultSpecifier
1866
+ | ImportNamespaceSpecifier;
1867
+
1868
+ /**
1869
+ * e.g. `import foo from 'mod.js'`
1870
+ */
1871
+ export interface ImportDefaultSpecifier extends Node, HasSpan {
1872
+ type: "ImportDefaultSpecifier";
1873
+ local: Identifier;
1874
+ }
1875
+
1876
+ /**
1877
+ * e.g. `import * as foo from 'mod.js'`.
1878
+ */
1879
+ export interface ImportNamespaceSpecifier extends Node, HasSpan {
1880
+ type: "ImportNamespaceSpecifier";
1881
+
1882
+ local: Identifier;
1883
+ }
1884
+
1885
+ /**
1886
+ * e.g. - `import { foo } from 'mod.js'`
1887
+ *
1888
+ * local = foo, imported = None
1889
+ *
1890
+ * e.g. `import { foo as bar } from 'mod.js'`
1891
+ *
1892
+ * local = bar, imported = Some(foo) for
1893
+ */
1894
+ export interface NamedImportSpecifier extends Node, HasSpan {
1895
+ type: "ImportSpecifier";
1896
+ local: Identifier;
1897
+ imported?: ModuleExportName;
1898
+ isTypeOnly: boolean;
1899
+ }
1900
+
1901
+ export type ModuleExportName = Identifier | StringLiteral;
1902
+
1903
+ export type ExportSpecifier =
1904
+ | ExportNamespaceSpecifier
1905
+ | ExportDefaultSpecifier
1906
+ | NamedExportSpecifier;
1907
+
1908
+ /**
1909
+ * `export * as foo from 'src';`
1910
+ */
1911
+ export interface ExportNamespaceSpecifier extends Node, HasSpan {
1912
+ type: "ExportNamespaceSpecifier";
1913
+
1914
+ name: ModuleExportName;
1915
+ }
1916
+
1917
+ export interface ExportDefaultSpecifier extends Node, HasSpan {
1918
+ type: "ExportDefaultSpecifier";
1919
+
1920
+ exported: Identifier;
1921
+ }
1922
+
1923
+ export interface NamedExportSpecifier extends Node, HasSpan {
1924
+ type: "ExportSpecifier";
1925
+
1926
+ orig: ModuleExportName;
1927
+ /**
1928
+ * `Some(bar)` in `export { foo as bar }`
1929
+ */
1930
+ exported?: ModuleExportName;
1931
+ isTypeOnly: boolean;
1932
+ }
1933
+
1934
+ interface HasInterpreter {
1935
+ /**
1936
+ * e.g. `/usr/bin/node` for `#!/usr/bin/node`
1937
+ */
1938
+ interpreter: string;
1939
+ }
1940
+
1941
+ export type Program = Module | Script;
1942
+
1943
+ export interface Module extends Node, HasSpan, HasInterpreter {
1944
+ type: "Module";
1945
+
1946
+ body: ModuleItem[];
1947
+ }
1948
+
1949
+ export interface Script extends Node, HasSpan, HasInterpreter {
1950
+ type: "Script";
1951
+
1952
+ body: Statement[];
1953
+ }
1954
+
1955
+ export type ModuleItem = ModuleDeclaration | Statement;
1956
+
1957
+ export type BinaryOperator =
1958
+ | "=="
1959
+ | "!="
1960
+ | "==="
1961
+ | "!=="
1962
+ | "<"
1963
+ | "<="
1964
+ | ">"
1965
+ | ">="
1966
+ | "<<"
1967
+ | ">>"
1968
+ | ">>>"
1969
+ | "+"
1970
+ | "-"
1971
+ | "*"
1972
+ | "/"
1973
+ | "%"
1974
+ | "|"
1975
+ | "^"
1976
+ | "&"
1977
+ | "||"
1978
+ | "&&"
1979
+ | "in"
1980
+ | "instanceof"
1981
+ | "**"
1982
+ | "??";
1983
+
1984
+ export type AssignmentOperator =
1985
+ | "="
1986
+ | "+="
1987
+ | "-="
1988
+ | "*="
1989
+ | "/="
1990
+ | "%="
1991
+ | "<<="
1992
+ | ">>="
1993
+ | ">>>="
1994
+ | "|="
1995
+ | "^="
1996
+ | "&="
1997
+ | "**="
1998
+ | "&&="
1999
+ | "||="
2000
+ | "??=";
2001
+
2002
+ export type UpdateOperator = "++" | "--";
2003
+
2004
+ export type UnaryOperator =
2005
+ | "-"
2006
+ | "+"
2007
+ | "!"
2008
+ | "~"
2009
+ | "typeof"
2010
+ | "void"
2011
+ | "delete";
2012
+
2013
+ export type Pattern =
2014
+ | BindingIdentifier
2015
+ | ArrayPattern
2016
+ | RestElement
2017
+ | ObjectPattern
2018
+ | AssignmentPattern
2019
+ | Invalid
2020
+ | Expression;
2021
+
2022
+ export interface BindingIdentifier extends PatternBase {
2023
+ type: "Identifier";
2024
+ value: string;
2025
+ optional: boolean;
2026
+ }
2027
+
2028
+ export interface ArrayPattern extends PatternBase {
2029
+ type: "ArrayPattern";
2030
+
2031
+ elements: (Pattern | undefined)[];
2032
+
2033
+ optional: boolean;
2034
+ }
2035
+
2036
+ export interface ObjectPattern extends PatternBase {
2037
+ type: "ObjectPattern";
2038
+
2039
+ properties: ObjectPatternProperty[];
2040
+
2041
+ optional: boolean;
2042
+ }
2043
+
2044
+ export interface AssignmentPattern extends PatternBase {
2045
+ type: "AssignmentPattern";
2046
+
2047
+ left: Pattern;
2048
+ right: Expression;
2049
+ }
2050
+
2051
+ export interface RestElement extends PatternBase {
2052
+ type: "RestElement";
2053
+
2054
+ rest: Span;
2055
+
2056
+ argument: Pattern;
2057
+ }
2058
+
2059
+ export type ObjectPatternProperty =
2060
+ | KeyValuePatternProperty
2061
+ | AssignmentPatternProperty
2062
+ | RestElement;
2063
+
2064
+ /**
2065
+ * `{key: value}`
2066
+ */
2067
+ export interface KeyValuePatternProperty extends Node {
2068
+ type: "KeyValuePatternProperty";
2069
+
2070
+ key: PropertyName;
2071
+ value: Pattern;
2072
+ }
2073
+
2074
+ /**
2075
+ * `{key}` or `{key = value}`
2076
+ */
2077
+ export interface AssignmentPatternProperty extends Node, HasSpan {
2078
+ type: "AssignmentPatternProperty";
2079
+
2080
+ key: Identifier;
2081
+ value?: Expression;
2082
+ }
2083
+
2084
+ /** Identifier is `a` in `{ a, }` */
2085
+ export type Property =
2086
+ | Identifier
2087
+ | KeyValueProperty
2088
+ | AssignmentProperty
2089
+ | GetterProperty
2090
+ | SetterProperty
2091
+ | MethodProperty;
2092
+
2093
+ interface PropBase extends Node {
2094
+ key: PropertyName;
2095
+ }
2096
+
2097
+ export interface KeyValueProperty extends PropBase {
2098
+ type: "KeyValueProperty";
2099
+
2100
+ value: Expression;
2101
+ }
2102
+
2103
+ export interface AssignmentProperty extends Node {
2104
+ type: "AssignmentProperty";
2105
+
2106
+ key: Identifier;
2107
+ value: Expression;
2108
+ }
2109
+
2110
+ export interface GetterProperty extends PropBase, HasSpan {
2111
+ type: "GetterProperty";
2112
+
2113
+ typeAnnotation?: TsTypeAnnotation;
2114
+
2115
+ body?: BlockStatement;
2116
+ }
2117
+
2118
+ export interface SetterProperty extends PropBase, HasSpan {
2119
+ type: "SetterProperty";
2120
+
2121
+ param: Pattern;
2122
+ body?: BlockStatement;
2123
+ }
2124
+
2125
+ export interface MethodProperty extends PropBase, Fn {
2126
+ type: "MethodProperty";
2127
+ }
2128
+
2129
+ export type PropertyName =
2130
+ | Identifier
2131
+ | StringLiteral
2132
+ | NumericLiteral
2133
+ | ComputedPropName
2134
+ | BigIntLiteral;
2135
+
2136
+ export interface ComputedPropName extends Node, HasSpan {
2137
+ type: "Computed";
2138
+ expression: Expression;
2139
+ }
2140
+
2141
+ export interface BlockStatement extends Node, HasSpan {
2142
+ type: "BlockStatement";
2143
+
2144
+ stmts: Statement[];
2145
+ }
2146
+
2147
+ export interface ExpressionStatement extends Node, HasSpan {
2148
+ type: "ExpressionStatement";
2149
+ expression: Expression;
2150
+ }
2151
+
2152
+ export type Statement =
2153
+ | BlockStatement
2154
+ | EmptyStatement
2155
+ | DebuggerStatement
2156
+ | WithStatement
2157
+ | ReturnStatement
2158
+ | LabeledStatement
2159
+ | BreakStatement
2160
+ | ContinueStatement
2161
+ | IfStatement
2162
+ | SwitchStatement
2163
+ | ThrowStatement
2164
+ | TryStatement
2165
+ | WhileStatement
2166
+ | DoWhileStatement
2167
+ | ForStatement
2168
+ | ForInStatement
2169
+ | ForOfStatement
2170
+ | Declaration
2171
+ | ExpressionStatement;
2172
+
2173
+ export interface EmptyStatement extends Node, HasSpan {
2174
+ type: "EmptyStatement";
2175
+ }
2176
+
2177
+ export interface DebuggerStatement extends Node, HasSpan {
2178
+ type: "DebuggerStatement";
2179
+ }
2180
+
2181
+ export interface WithStatement extends Node, HasSpan {
2182
+ type: "WithStatement";
2183
+
2184
+ object: Expression;
2185
+ body: Statement;
2186
+ }
2187
+
2188
+ export interface ReturnStatement extends Node, HasSpan {
2189
+ type: "ReturnStatement";
2190
+
2191
+ argument?: Expression;
2192
+ }
2193
+
2194
+ export interface LabeledStatement extends Node, HasSpan {
2195
+ type: "LabeledStatement";
2196
+
2197
+ label: Identifier;
2198
+ body: Statement;
2199
+ }
2200
+
2201
+ export interface BreakStatement extends Node, HasSpan {
2202
+ type: "BreakStatement";
2203
+
2204
+ label?: Identifier;
2205
+ }
2206
+
2207
+ export interface ContinueStatement extends Node, HasSpan {
2208
+ type: "ContinueStatement";
2209
+
2210
+ label?: Identifier;
2211
+ }
2212
+
2213
+ export interface IfStatement extends Node, HasSpan {
2214
+ type: "IfStatement";
2215
+
2216
+ test: Expression;
2217
+ consequent: Statement;
2218
+ alternate?: Statement;
2219
+ }
2220
+
2221
+ export interface SwitchStatement extends Node, HasSpan {
2222
+ type: "SwitchStatement";
2223
+
2224
+ discriminant: Expression;
2225
+ cases: SwitchCase[];
2226
+ }
2227
+
2228
+ export interface ThrowStatement extends Node, HasSpan {
2229
+ type: "ThrowStatement";
2230
+
2231
+ argument: Expression;
2232
+ }
2233
+
2234
+ export interface TryStatement extends Node, HasSpan {
2235
+ type: "TryStatement";
2236
+
2237
+ block: BlockStatement;
2238
+ handler?: CatchClause;
2239
+ finalizer?: BlockStatement;
2240
+ }
2241
+
2242
+ export interface WhileStatement extends Node, HasSpan {
2243
+ type: "WhileStatement";
2244
+
2245
+ test: Expression;
2246
+ body: Statement;
2247
+ }
2248
+
2249
+ export interface DoWhileStatement extends Node, HasSpan {
2250
+ type: "DoWhileStatement";
2251
+
2252
+ test: Expression;
2253
+ body: Statement;
2254
+ }
2255
+
2256
+ export interface ForStatement extends Node, HasSpan {
2257
+ type: "ForStatement";
2258
+
2259
+ init?: VariableDeclaration | Expression;
2260
+ test?: Expression;
2261
+ update?: Expression;
2262
+ body: Statement;
2263
+ }
2264
+
2265
+ export interface ForInStatement extends Node, HasSpan {
2266
+ type: "ForInStatement";
2267
+
2268
+ left: VariableDeclaration | Pattern;
2269
+ right: Expression;
2270
+ body: Statement;
2271
+ }
2272
+
2273
+ export interface ForOfStatement extends Node, HasSpan {
2274
+ type: "ForOfStatement";
2275
+
2276
+ /**
2277
+ * Span of the await token.
2278
+ *
2279
+ * es2018 for-await-of statements, e.g., `for await (const x of xs) {`
2280
+ */
2281
+ await?: Span;
2282
+ left: VariableDeclaration | Pattern;
2283
+ right: Expression;
2284
+ body: Statement;
2285
+ }
2286
+
2287
+ export interface SwitchCase extends Node, HasSpan {
2288
+ type: "SwitchCase";
2289
+
2290
+ /**
2291
+ * Undefined for default case
2292
+ */
2293
+ test?: Expression;
2294
+ consequent: Statement[];
2295
+ }
2296
+
2297
+ export interface CatchClause extends Node, HasSpan {
2298
+ type: "CatchClause";
2299
+
2300
+ /**
2301
+ * The param is `undefined` if the catch binding is omitted. E.g., `try { foo() } catch {}`
2302
+ */
2303
+ param?: Pattern;
2304
+ body: BlockStatement;
2305
+ }
2306
+
2307
+ export interface TsTypeAnnotation extends Node, HasSpan {
2308
+ type: "TsTypeAnnotation";
2309
+
2310
+ typeAnnotation: TsType;
2311
+ }
2312
+
2313
+ export interface TsTypeParameterDeclaration extends Node, HasSpan {
2314
+ type: "TsTypeParameterDeclaration";
2315
+
2316
+ parameters: TsTypeParameter[];
2317
+ }
2318
+
2319
+ export interface TsTypeParameter extends Node, HasSpan {
2320
+ type: "TsTypeParameter";
2321
+
2322
+ name: Identifier;
2323
+ in: boolean;
2324
+ out: boolean;
2325
+ constraint?: TsType;
2326
+ default?: TsType;
2327
+ }
2328
+
2329
+ export interface TsTypeParameterInstantiation extends Node, HasSpan {
2330
+ type: "TsTypeParameterInstantiation";
2331
+
2332
+ params: TsType[];
2333
+ }
2334
+
2335
+ export interface TsParameterProperty extends Node, HasSpan, HasDecorator {
2336
+ type: "TsParameterProperty";
2337
+
2338
+ accessibility?: Accessibility;
2339
+ override: boolean;
2340
+ readonly: boolean;
2341
+ param: TsParameterPropertyParameter;
2342
+ }
2343
+
2344
+ export type TsParameterPropertyParameter =
2345
+ | BindingIdentifier
2346
+ | AssignmentPattern;
2347
+
2348
+ export interface TsQualifiedName extends Node {
2349
+ type: "TsQualifiedName";
2350
+
2351
+ left: TsEntityName;
2352
+ right: Identifier;
2353
+ }
2354
+
2355
+ export type TsEntityName = TsQualifiedName | Identifier;
2356
+
2357
+ export type TsTypeElement =
2358
+ | TsCallSignatureDeclaration
2359
+ | TsConstructSignatureDeclaration
2360
+ | TsPropertySignature
2361
+ | TsGetterSignature
2362
+ | TsSetterSignature
2363
+ | TsMethodSignature
2364
+ | TsIndexSignature;
2365
+
2366
+ export interface TsCallSignatureDeclaration extends Node, HasSpan {
2367
+ type: "TsCallSignatureDeclaration";
2368
+
2369
+ params: TsFnParameter[];
2370
+ typeAnnotation?: TsTypeAnnotation;
2371
+ typeParams?: TsTypeParameterDeclaration;
2372
+ }
2373
+
2374
+ export interface TsConstructSignatureDeclaration extends Node, HasSpan {
2375
+ type: "TsConstructSignatureDeclaration";
2376
+
2377
+ params: TsFnParameter[];
2378
+ typeAnnotation?: TsTypeAnnotation;
2379
+ typeParams?: TsTypeParameterDeclaration;
2380
+ }
2381
+
2382
+ export interface TsPropertySignature extends Node, HasSpan {
2383
+ type: "TsPropertySignature";
2384
+
2385
+ readonly: boolean;
2386
+ key: Expression;
2387
+ computed: boolean;
2388
+ optional: boolean;
2389
+
2390
+ init?: Expression;
2391
+ params: TsFnParameter[];
2392
+
2393
+ typeAnnotation?: TsTypeAnnotation;
2394
+ typeParams?: TsTypeParameterDeclaration;
2395
+ }
2396
+
2397
+ export interface TsGetterSignature extends Node, HasSpan {
2398
+ type: "TsGetterSignature";
2399
+
2400
+ readonly: boolean;
2401
+ key: Expression;
2402
+ computed: boolean;
2403
+ optional: boolean;
2404
+ typeAnnotation?: TsTypeAnnotation;
2405
+ }
2406
+
2407
+ export interface TsSetterSignature extends Node, HasSpan {
2408
+ type: "TsSetterSignature";
2409
+
2410
+ readonly: boolean;
2411
+ key: Expression;
2412
+ computed: boolean;
2413
+ optional: boolean;
2414
+ param: TsFnParameter;
2415
+ }
2416
+
2417
+ export interface TsMethodSignature extends Node, HasSpan {
2418
+ type: "TsMethodSignature";
2419
+
2420
+ readonly: boolean;
2421
+ key: Expression;
2422
+ computed: boolean;
2423
+ optional: boolean;
2424
+ params: TsFnParameter[];
2425
+
2426
+ typeAnn?: TsTypeAnnotation;
2427
+ typeParams?: TsTypeParameterDeclaration;
2428
+ }
2429
+
2430
+ export interface TsIndexSignature extends Node, HasSpan {
2431
+ type: "TsIndexSignature";
2432
+
2433
+ params: TsFnParameter[];
2434
+
2435
+ typeAnnotation?: TsTypeAnnotation;
2436
+
2437
+ readonly: boolean;
2438
+ static: boolean;
2439
+ }
2440
+
2441
+ export type TsType =
2442
+ | TsKeywordType
2443
+ | TsThisType
2444
+ | TsFnOrConstructorType
2445
+ | TsTypeReference
2446
+ | TsTypeQuery
2447
+ | TsTypeLiteral
2448
+ | TsArrayType
2449
+ | TsTupleType
2450
+ | TsOptionalType
2451
+ | TsRestType
2452
+ | TsUnionOrIntersectionType
2453
+ | TsConditionalType
2454
+ | TsInferType
2455
+ | TsParenthesizedType
2456
+ | TsTypeOperator
2457
+ | TsIndexedAccessType
2458
+ | TsMappedType
2459
+ | TsLiteralType
2460
+ | TsTypePredicate
2461
+ | TsImportType;
2462
+
2463
+ export type TsFnOrConstructorType = TsFunctionType | TsConstructorType;
2464
+
2465
+ export interface TsKeywordType extends Node, HasSpan {
2466
+ type: "TsKeywordType";
2467
+
2468
+ kind: TsKeywordTypeKind;
2469
+ }
2470
+
2471
+ export type TsKeywordTypeKind =
2472
+ | "any"
2473
+ | "unknown"
2474
+ | "number"
2475
+ | "object"
2476
+ | "boolean"
2477
+ | "bigint"
2478
+ | "string"
2479
+ | "symbol"
2480
+ | "void"
2481
+ | "undefined"
2482
+ | "null"
2483
+ | "never"
2484
+ | "intrinsic";
2485
+
2486
+ export interface TsThisType extends Node, HasSpan {
2487
+ type: "TsThisType";
2488
+ }
2489
+
2490
+ export type TsFnParameter =
2491
+ | BindingIdentifier
2492
+ | ArrayPattern
2493
+ | RestElement
2494
+ | ObjectPattern;
2495
+
2496
+ export interface TsFunctionType extends Node, HasSpan {
2497
+ type: "TsFunctionType";
2498
+
2499
+ params: TsFnParameter[];
2500
+
2501
+ typeParams?: TsTypeParameterDeclaration;
2502
+ typeAnnotation: TsTypeAnnotation;
2503
+ }
2504
+
2505
+ export interface TsConstructorType extends Node, HasSpan {
2506
+ type: "TsConstructorType";
2507
+
2508
+ params: TsFnParameter[];
2509
+
2510
+ typeParams?: TsTypeParameterDeclaration;
2511
+ typeAnnotation: TsTypeAnnotation;
2512
+ isAbstract: boolean;
2513
+ }
2514
+
2515
+ export interface TsTypeReference extends Node, HasSpan {
2516
+ type: "TsTypeReference";
2517
+
2518
+ typeName: TsEntityName;
2519
+ typeParams?: TsTypeParameterInstantiation;
2520
+ }
2521
+
2522
+ export interface TsTypePredicate extends Node, HasSpan {
2523
+ type: "TsTypePredicate";
2524
+
2525
+ asserts: boolean;
2526
+
2527
+ paramName: TsThisTypeOrIdent;
2528
+ typeAnnotation?: TsTypeAnnotation;
2529
+ }
2530
+
2531
+ export type TsThisTypeOrIdent = TsThisType | Identifier;
2532
+
2533
+ export interface TsImportType extends Node, HasSpan {
2534
+ type: "TsImportType";
2535
+
2536
+ argument: StringLiteral;
2537
+ qualifier?: TsEntityName;
2538
+ typeArguments?: TsTypeParameterInstantiation;
2539
+ }
2540
+
2541
+ /**
2542
+ * `typeof` operator
2543
+ */
2544
+ export interface TsTypeQuery extends Node, HasSpan {
2545
+ type: "TsTypeQuery";
2546
+
2547
+ exprName: TsTypeQueryExpr;
2548
+ typeArguments?: TsTypeParameterInstantiation;
2549
+ }
2550
+
2551
+ export type TsTypeQueryExpr = TsEntityName | TsImportType;
2552
+
2553
+ export interface TsTypeLiteral extends Node, HasSpan {
2554
+ type: "TsTypeLiteral";
2555
+
2556
+ members: TsTypeElement[];
2557
+ }
2558
+
2559
+ export interface TsArrayType extends Node, HasSpan {
2560
+ type: "TsArrayType";
2561
+
2562
+ elemType: TsType;
2563
+ }
2564
+
2565
+ export interface TsTupleType extends Node, HasSpan {
2566
+ type: "TsTupleType";
2567
+
2568
+ elemTypes: TsTupleElement[];
2569
+ }
2570
+
2571
+ export interface TsTupleElement extends Node, HasSpan {
2572
+ type: "TsTupleElement";
2573
+
2574
+ label?: Pattern;
2575
+ ty: TsType;
2576
+ }
2577
+
2578
+ export interface TsOptionalType extends Node, HasSpan {
2579
+ type: "TsOptionalType";
2580
+
2581
+ typeAnnotation: TsType;
2582
+ }
2583
+
2584
+ export interface TsRestType extends Node, HasSpan {
2585
+ type: "TsRestType";
2586
+
2587
+ typeAnnotation: TsType;
2588
+ }
2589
+
2590
+ export type TsUnionOrIntersectionType = TsUnionType | TsIntersectionType;
2591
+
2592
+ export interface TsUnionType extends Node, HasSpan {
2593
+ type: "TsUnionType";
2594
+
2595
+ types: TsType[];
2596
+ }
2597
+
2598
+ export interface TsIntersectionType extends Node, HasSpan {
2599
+ type: "TsIntersectionType";
2600
+
2601
+ types: TsType[];
2602
+ }
2603
+
2604
+ export interface TsConditionalType extends Node, HasSpan {
2605
+ type: "TsConditionalType";
2606
+
2607
+ checkType: TsType;
2608
+ extendsType: TsType;
2609
+ trueType: TsType;
2610
+ falseType: TsType;
2611
+ }
2612
+
2613
+ export interface TsInferType extends Node, HasSpan {
2614
+ type: "TsInferType";
2615
+
2616
+ typeParam: TsTypeParameter;
2617
+ }
2618
+
2619
+ export interface TsParenthesizedType extends Node, HasSpan {
2620
+ type: "TsParenthesizedType";
2621
+
2622
+ typeAnnotation: TsType;
2623
+ }
2624
+
2625
+ export interface TsTypeOperator extends Node, HasSpan {
2626
+ type: "TsTypeOperator";
2627
+
2628
+ op: TsTypeOperatorOp;
2629
+ typeAnnotation: TsType;
2630
+ }
2631
+
2632
+ export type TsTypeOperatorOp = "keyof" | "unique" | "readonly";
2633
+
2634
+ export interface TsIndexedAccessType extends Node, HasSpan {
2635
+ type: "TsIndexedAccessType";
2636
+
2637
+ readonly: boolean;
2638
+ objectType: TsType;
2639
+ indexType: TsType;
2640
+ }
2641
+
2642
+ export type TruePlusMinus = true | "+" | "-";
2643
+
2644
+ export interface TsMappedType extends Node, HasSpan {
2645
+ type: "TsMappedType";
2646
+
2647
+ readonly?: TruePlusMinus;
2648
+ typeParam: TsTypeParameter;
2649
+ nameType?: TsType;
2650
+ optional?: TruePlusMinus;
2651
+ typeAnnotation?: TsType;
2652
+ }
2653
+
2654
+ export interface TsLiteralType extends Node, HasSpan {
2655
+ type: "TsLiteralType";
2656
+
2657
+ literal: TsLiteral;
2658
+ }
2659
+
2660
+ export type TsLiteral =
2661
+ | NumericLiteral
2662
+ | StringLiteral
2663
+ | BooleanLiteral
2664
+ | BigIntLiteral
2665
+ | TsTemplateLiteralType;
2666
+
2667
+ export interface TsTemplateLiteralType extends Node, HasSpan {
2668
+ type: "TemplateLiteral";
2669
+ types: TsType[];
2670
+ quasis: TemplateElement[];
2671
+ }
2672
+
2673
+ // // ================
2674
+ // // TypeScript declarations
2675
+ // // ================
2676
+
2677
+ export interface TsInterfaceDeclaration extends Node, HasSpan {
2678
+ type: "TsInterfaceDeclaration";
2679
+
2680
+ id: Identifier;
2681
+ declare: boolean;
2682
+ typeParams?: TsTypeParameterDeclaration;
2683
+ extends: TsExpressionWithTypeArguments[];
2684
+ body: TsInterfaceBody;
2685
+ }
2686
+
2687
+ export interface TsInterfaceBody extends Node, HasSpan {
2688
+ type: "TsInterfaceBody";
2689
+
2690
+ body: TsTypeElement[];
2691
+ }
2692
+
2693
+ export interface TsExpressionWithTypeArguments extends Node, HasSpan {
2694
+ type: "TsExpressionWithTypeArguments";
2695
+
2696
+ expression: Expression;
2697
+ typeArguments?: TsTypeParameterInstantiation;
2698
+ }
2699
+
2700
+ export interface TsTypeAliasDeclaration extends Node, HasSpan {
2701
+ type: "TsTypeAliasDeclaration";
2702
+
2703
+ declare: boolean;
2704
+ id: Identifier;
2705
+ typeParams?: TsTypeParameterDeclaration;
2706
+ typeAnnotation: TsType;
2707
+ }
2708
+
2709
+ export interface TsEnumDeclaration extends Node, HasSpan {
2710
+ type: "TsEnumDeclaration";
2711
+
2712
+ declare: boolean;
2713
+ isConst: boolean;
2714
+ id: Identifier;
2715
+ members: TsEnumMember[];
2716
+ }
2717
+
2718
+ export interface TsEnumMember extends Node, HasSpan {
2719
+ type: "TsEnumMember";
2720
+
2721
+ id: TsEnumMemberId;
2722
+ init?: Expression;
2723
+ }
2724
+
2725
+ export type TsEnumMemberId = Identifier | StringLiteral;
2726
+
2727
+ export interface TsModuleDeclaration extends Node, HasSpan {
2728
+ type: "TsModuleDeclaration";
2729
+
2730
+ declare: boolean;
2731
+ global: boolean;
2732
+ id: TsModuleName;
2733
+ body?: TsNamespaceBody;
2734
+ }
2735
+
3
2736
  /**
4
- * @param {string} s
5
- * @param {any} opts
6
- * @returns {any}
7
- */
8
- export function minifySync(s: string, opts: any): any;
9
- /**
10
- * @param {string} s
11
- * @param {any} opts
12
- * @returns {any}
13
- */
14
- export function parseSync(s: string, opts: any): any;
15
- /**
16
- * @param {any} s
17
- * @param {any} opts
18
- * @returns {any}
19
- */
20
- export function printSync(s: any, opts: any): any;
21
-
22
- /**
23
- * @param {string} code
24
- * @param {any} opts
25
- * @param {Record<string, ArrayBuffer>} experimental_plugin_bytes_resolver An object contains bytes array for the plugin
26
- * specified in config. Key of record represents the name of the plugin specified in config. Note this is an experimental
27
- * interface, likely will change.
28
- * @returns {any}
29
- */
30
- export function transformSync(code: string, opts: any, experimental_plugin_bytes_resolver?: any): any;
2737
+ * `namespace A.B { }` is a namespace named `A` with another TsNamespaceDecl as its body.
2738
+ */
2739
+ export type TsNamespaceBody = TsModuleBlock | TsNamespaceDeclaration;
2740
+
2741
+ export interface TsModuleBlock extends Node, HasSpan {
2742
+ type: "TsModuleBlock";
2743
+
2744
+ body: ModuleItem[];
2745
+ }
2746
+
2747
+ export interface TsNamespaceDeclaration extends Node, HasSpan {
2748
+ type: "TsNamespaceDeclaration";
2749
+
2750
+ declare: boolean;
2751
+ global: boolean;
2752
+ id: Identifier;
2753
+ body: TsNamespaceBody;
2754
+ }
2755
+
2756
+ export type TsModuleName = Identifier | StringLiteral;
2757
+
2758
+ export interface TsImportEqualsDeclaration extends Node, HasSpan {
2759
+ type: "TsImportEqualsDeclaration";
2760
+
2761
+ declare: boolean;
2762
+ isExport: boolean;
2763
+ isTypeOnly: boolean;
2764
+ id: Identifier;
2765
+ moduleRef: TsModuleReference;
2766
+ }
2767
+
2768
+ export type TsModuleReference = TsEntityName | TsExternalModuleReference;
2769
+
2770
+ export interface TsExternalModuleReference extends Node, HasSpan {
2771
+ type: "TsExternalModuleReference";
2772
+
2773
+ expression: StringLiteral;
2774
+ }
2775
+
2776
+ export interface TsExportAssignment extends Node, HasSpan {
2777
+ type: "TsExportAssignment";
2778
+
2779
+ expression: Expression;
2780
+ }
2781
+
2782
+ export interface TsNamespaceExportDeclaration extends Node, HasSpan {
2783
+ type: "TsNamespaceExportDeclaration";
2784
+
2785
+ id: Identifier;
2786
+ }
2787
+
2788
+ export interface TsAsExpression extends ExpressionBase {
2789
+ type: "TsAsExpression";
2790
+
2791
+ expression: Expression;
2792
+ typeAnnotation: TsType;
2793
+ }
2794
+
2795
+ export interface TsInstantiation extends Node, HasSpan {
2796
+ type: "TsInstantiation";
2797
+
2798
+ expression: Expression;
2799
+ typeArguments: TsTypeParameterInstantiation;
2800
+ }
2801
+
2802
+ export interface TsTypeAssertion extends ExpressionBase {
2803
+ type: "TsTypeAssertion";
2804
+
2805
+ expression: Expression;
2806
+ typeAnnotation: TsType;
2807
+ }
2808
+
2809
+ export interface TsConstAssertion extends ExpressionBase {
2810
+ type: "TsConstAssertion";
2811
+
2812
+ expression: Expression;
2813
+ }
2814
+
2815
+ export interface TsNonNullExpression extends ExpressionBase {
2816
+ type: "TsNonNullExpression";
2817
+
2818
+ expression: Expression;
2819
+ }
2820
+
2821
+ export type Accessibility = "public" | "protected" | "private";
2822
+
2823
+ export interface Invalid extends Node, HasSpan {
2824
+ type: "Invalid";
2825
+ }
31
2826
 
32
2827