@swc/wasm 1.2.220 → 1.2.221

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