@storybook/telemetry 7.6.0-alpha.4 → 7.6.0-alpha.5

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 (2) hide show
  1. package/dist/index.d.ts +1932 -5
  2. package/package.json +4 -4
package/dist/index.d.ts CHANGED
@@ -728,6 +728,1886 @@ interface Parameters {
728
728
  [name: string]: any;
729
729
  }
730
730
 
731
+ interface Plugin {
732
+ (module: Program): Program;
733
+ }
734
+ type TerserEcmaVersion = 5 | 2015 | 2016 | string | number;
735
+ interface JsMinifyOptions {
736
+ compress?: TerserCompressOptions | boolean;
737
+ format?: JsFormatOptions & ToSnakeCaseProperties<JsFormatOptions>;
738
+ mangle?: TerserMangleOptions | boolean;
739
+ ecma?: TerserEcmaVersion;
740
+ keep_classnames?: boolean;
741
+ keep_fnames?: boolean;
742
+ module?: boolean;
743
+ safari10?: boolean;
744
+ toplevel?: boolean;
745
+ sourceMap?: boolean;
746
+ outputPath?: string;
747
+ inlineSourcesContent?: boolean;
748
+ }
749
+ /**
750
+ * @example ToSnakeCase<'indentLevel'> == 'indent_level'
751
+ */
752
+ type ToSnakeCase<T extends string> = T extends `${infer A}${infer B}` ? `${A extends Lowercase<A> ? A : `_${Lowercase<A>}`}${ToSnakeCase<B>}` : T;
753
+ /**
754
+ * @example ToSnakeCaseProperties<{indentLevel: 3}> == {indent_level: 3}
755
+ */
756
+ type ToSnakeCaseProperties<T> = {
757
+ [K in keyof T as K extends string ? ToSnakeCase<K> : K]: T[K];
758
+ };
759
+ /**
760
+ * These properties are mostly not implemented yet,
761
+ * but it exists to support passing terser config to swc minify
762
+ * without modification.
763
+ */
764
+ interface JsFormatOptions {
765
+ /**
766
+ * Currently noop.
767
+ * @default false
768
+ * @alias ascii_only
769
+ */
770
+ asciiOnly?: boolean;
771
+ /**
772
+ * Currently noop.
773
+ * @default false
774
+ */
775
+ beautify?: boolean;
776
+ /**
777
+ * Currently noop.
778
+ * @default false
779
+ */
780
+ braces?: boolean;
781
+ /**
782
+ * - `false`: removes all comments
783
+ * - `'some'`: preserves some comments
784
+ * - `'all'`: preserves all comments
785
+ * @default false
786
+ */
787
+ comments?: false | "some" | "all";
788
+ /**
789
+ * Currently noop.
790
+ * @default 5
791
+ */
792
+ ecma?: TerserEcmaVersion;
793
+ /**
794
+ * Currently noop.
795
+ * @alias indent_level
796
+ */
797
+ indentLevel?: number;
798
+ /**
799
+ * Currently noop.
800
+ * @alias indent_start
801
+ */
802
+ indentStart?: number;
803
+ /**
804
+ * Currently noop.
805
+ * @alias inline_script
806
+ */
807
+ inlineScript?: number;
808
+ /**
809
+ * Currently noop.
810
+ * @alias keep_numbers
811
+ */
812
+ keepNumbers?: number;
813
+ /**
814
+ * Currently noop.
815
+ * @alias keep_quoted_props
816
+ */
817
+ keepQuotedProps?: boolean;
818
+ /**
819
+ * Currently noop.
820
+ * @alias max_line_len
821
+ */
822
+ maxLineLen?: number | false;
823
+ /**
824
+ * Currently noop.
825
+ */
826
+ preamble?: string;
827
+ /**
828
+ * Currently noop.
829
+ * @alias quote_keys
830
+ */
831
+ quoteKeys?: boolean;
832
+ /**
833
+ * Currently noop.
834
+ * @alias quote_style
835
+ */
836
+ quoteStyle?: boolean;
837
+ /**
838
+ * Currently noop.
839
+ * @alias preserve_annotations
840
+ */
841
+ preserveAnnotations?: boolean;
842
+ /**
843
+ * Currently noop.
844
+ */
845
+ safari10?: boolean;
846
+ /**
847
+ * Currently noop.
848
+ */
849
+ semicolons?: boolean;
850
+ /**
851
+ * Currently noop.
852
+ */
853
+ shebang?: boolean;
854
+ /**
855
+ * Currently noop.
856
+ */
857
+ webkit?: boolean;
858
+ /**
859
+ * Currently noop.
860
+ * @alias wrap_iife
861
+ */
862
+ wrapIife?: boolean;
863
+ /**
864
+ * Currently noop.
865
+ * @alias wrap_func_args
866
+ */
867
+ wrapFuncArgs?: boolean;
868
+ }
869
+ interface TerserCompressOptions {
870
+ arguments?: boolean;
871
+ arrows?: boolean;
872
+ booleans?: boolean;
873
+ booleans_as_integers?: boolean;
874
+ collapse_vars?: boolean;
875
+ comparisons?: boolean;
876
+ computed_props?: boolean;
877
+ conditionals?: boolean;
878
+ dead_code?: boolean;
879
+ defaults?: boolean;
880
+ directives?: boolean;
881
+ drop_console?: boolean;
882
+ drop_debugger?: boolean;
883
+ ecma?: TerserEcmaVersion;
884
+ evaluate?: boolean;
885
+ expression?: boolean;
886
+ global_defs?: any;
887
+ hoist_funs?: boolean;
888
+ hoist_props?: boolean;
889
+ hoist_vars?: boolean;
890
+ ie8?: boolean;
891
+ if_return?: boolean;
892
+ inline?: 0 | 1 | 2 | 3;
893
+ join_vars?: boolean;
894
+ keep_classnames?: boolean;
895
+ keep_fargs?: boolean;
896
+ keep_fnames?: boolean;
897
+ keep_infinity?: boolean;
898
+ loops?: boolean;
899
+ negate_iife?: boolean;
900
+ passes?: number;
901
+ properties?: boolean;
902
+ pure_getters?: any;
903
+ pure_funcs?: string[];
904
+ reduce_funcs?: boolean;
905
+ reduce_vars?: boolean;
906
+ sequences?: any;
907
+ side_effects?: boolean;
908
+ switches?: boolean;
909
+ top_retain?: any;
910
+ toplevel?: any;
911
+ typeofs?: boolean;
912
+ unsafe?: boolean;
913
+ unsafe_passes?: boolean;
914
+ unsafe_arrows?: boolean;
915
+ unsafe_comps?: boolean;
916
+ unsafe_function?: boolean;
917
+ unsafe_math?: boolean;
918
+ unsafe_symbols?: boolean;
919
+ unsafe_methods?: boolean;
920
+ unsafe_proto?: boolean;
921
+ unsafe_regexp?: boolean;
922
+ unsafe_undefined?: boolean;
923
+ unused?: boolean;
924
+ const_to_let?: boolean;
925
+ module?: boolean;
926
+ }
927
+ interface TerserMangleOptions {
928
+ props?: TerserManglePropertiesOptions;
929
+ toplevel?: boolean;
930
+ keep_classnames?: boolean;
931
+ keep_fnames?: boolean;
932
+ keep_private_props?: boolean;
933
+ ie8?: boolean;
934
+ safari10?: boolean;
935
+ reserved?: string[];
936
+ }
937
+ interface TerserManglePropertiesOptions {
938
+ }
939
+ /**
940
+ * Programmatic options.
941
+ */
942
+ interface Options$2 extends Config {
943
+ /**
944
+ * If true, a file is parsed as a script instead of module.
945
+ */
946
+ script?: boolean;
947
+ /**
948
+ * The working directory that all paths in the programmatic
949
+ * options will be resolved relative to.
950
+ *
951
+ * Defaults to `process.cwd()`.
952
+ */
953
+ cwd?: string;
954
+ caller?: CallerOptions;
955
+ /** The filename associated with the code currently being compiled,
956
+ * if there is one. The filename is optional, but not all of Swc's
957
+ * functionality is available when the filename is unknown, because a
958
+ * subset of options rely on the filename for their functionality.
959
+ *
960
+ * The three primary cases users could run into are:
961
+ *
962
+ * - The filename is exposed to plugins. Some plugins may require the
963
+ * presence of the filename.
964
+ * - Options like "test", "exclude", and "ignore" require the filename
965
+ * for string/RegExp matching.
966
+ * - .swcrc files are loaded relative to the file being compiled.
967
+ * If this option is omitted, Swc will behave as if swcrc: false has been set.
968
+ */
969
+ filename?: string;
970
+ /**
971
+ * The initial path that will be processed based on the "rootMode" to
972
+ * determine the conceptual root folder for the current Swc project.
973
+ * This is used in two primary cases:
974
+ *
975
+ * - The base directory when checking for the default "configFile" value
976
+ * - The default value for "swcrcRoots".
977
+ *
978
+ * Defaults to `opts.cwd`
979
+ */
980
+ root?: string;
981
+ /**
982
+ * This option, combined with the "root" value, defines how Swc chooses
983
+ * its project root. The different modes define different ways that Swc
984
+ * can process the "root" value to get the final project root.
985
+ *
986
+ * "root" - Passes the "root" value through as unchanged.
987
+ * "upward" - Walks upward from the "root" directory, looking for a directory
988
+ * containing a swc.config.js file, and throws an error if a swc.config.js
989
+ * is not found.
990
+ * "upward-optional" - Walk upward from the "root" directory, looking for
991
+ * a directory containing a swc.config.js file, and falls back to "root"
992
+ * if a swc.config.js is not found.
993
+ *
994
+ *
995
+ * "root" is the default mode because it avoids the risk that Swc
996
+ * will accidentally load a swc.config.js that is entirely outside
997
+ * of the current project folder. If you use "upward-optional",
998
+ * be aware that it will walk up the directory structure all the
999
+ * way to the filesystem root, and it is always possible that someone
1000
+ * will have a forgotten swc.config.js in their home directory,
1001
+ * which could cause unexpected errors in your builds.
1002
+ *
1003
+ *
1004
+ * Users with monorepo project structures that run builds/tests on a
1005
+ * per-package basis may well want to use "upward" since monorepos
1006
+ * often have a swc.config.js in the project root. Running Swc
1007
+ * in a monorepo subdirectory without "upward", will cause Swc
1008
+ * to skip loading any swc.config.js files in the project root,
1009
+ * which can lead to unexpected errors and compilation failure.
1010
+ */
1011
+ rootMode?: "root" | "upward" | "upward-optional";
1012
+ /**
1013
+ * The current active environment used during configuration loading.
1014
+ * This value is used as the key when resolving "env" configs,
1015
+ * and is also available inside configuration functions, plugins,
1016
+ * and presets, via the api.env() function.
1017
+ *
1018
+ * Defaults to `process.env.SWC_ENV || process.env.NODE_ENV || "development"`
1019
+ */
1020
+ envName?: string;
1021
+ /**
1022
+ * Defaults to searching for a default `.swcrc` file, but can
1023
+ * be passed the path of any JS or JSON5 config file.
1024
+ *
1025
+ *
1026
+ * NOTE: This option does not affect loading of .swcrc files,
1027
+ * so while it may be tempting to do configFile: "./foo/.swcrc",
1028
+ * it is not recommended. If the given .swcrc is loaded via the
1029
+ * standard file-relative logic, you'll end up loading the same
1030
+ * config file twice, merging it with itself. If you are linking
1031
+ * a specific config file, it is recommended to stick with a
1032
+ * naming scheme that is independent of the "swcrc" name.
1033
+ *
1034
+ * Defaults to `path.resolve(opts.root, ".swcrc")`
1035
+ */
1036
+ configFile?: string | boolean;
1037
+ /**
1038
+ * true will enable searching for configuration files relative to the "filename" provided to Swc.
1039
+ *
1040
+ * A swcrc value passed in the programmatic options will override one set within a configuration file.
1041
+ *
1042
+ * Note: .swcrc files are only loaded if the current "filename" is inside of
1043
+ * a package that matches one of the "swcrcRoots" packages.
1044
+ *
1045
+ *
1046
+ * Defaults to true as long as the filename option has been specified
1047
+ */
1048
+ swcrc?: boolean;
1049
+ /**
1050
+ * By default, Babel will only search for .babelrc files within the "root" package
1051
+ * because otherwise Babel cannot know if a given .babelrc is meant to be loaded,
1052
+ * or if it's "plugins" and "presets" have even been installed, since the file
1053
+ * being compiled could be inside node_modules, or have been symlinked into the project.
1054
+ *
1055
+ *
1056
+ * This option allows users to provide a list of other packages that should be
1057
+ * considered "root" packages when considering whether to load .babelrc files.
1058
+ *
1059
+ *
1060
+ * For example, a monorepo setup that wishes to allow individual packages
1061
+ * to have their own configs might want to do
1062
+ *
1063
+ *
1064
+ *
1065
+ * Defaults to `opts.root`
1066
+ */
1067
+ swcrcRoots?: boolean | MatchPattern | MatchPattern[];
1068
+ /**
1069
+ * `true` will attempt to load an input sourcemap from the file itself, if it
1070
+ * contains a //# sourceMappingURL=... comment. If no map is found, or the
1071
+ * map fails to load and parse, it will be silently discarded.
1072
+ *
1073
+ * If an object is provided, it will be treated as the source map object itself.
1074
+ *
1075
+ * Defaults to `true`.
1076
+ */
1077
+ inputSourceMap?: boolean | string;
1078
+ /**
1079
+ * The name to use for the file inside the source map object.
1080
+ *
1081
+ * Defaults to `path.basename(opts.filenameRelative)` when available, or `"unknown"`.
1082
+ */
1083
+ sourceFileName?: string;
1084
+ /**
1085
+ * The sourceRoot fields to set in the generated source map, if one is desired.
1086
+ */
1087
+ sourceRoot?: string;
1088
+ plugin?: Plugin;
1089
+ isModule?: boolean | "unknown";
1090
+ /**
1091
+ * Destination path. Note that this value is used only to fix source path
1092
+ * of source map files and swc does not write output to this path.
1093
+ */
1094
+ outputPath?: string;
1095
+ }
1096
+ interface CallerOptions {
1097
+ name: string;
1098
+ [key: string]: any;
1099
+ }
1100
+ /**
1101
+ * .swcrc
1102
+ */
1103
+ interface Config {
1104
+ /**
1105
+ * Note: The type is string because it follows rust's regex syntax.
1106
+ */
1107
+ test?: string | string[];
1108
+ /**
1109
+ * Note: The type is string because it follows rust's regex syntax.
1110
+ */
1111
+ exclude?: string | string[];
1112
+ env?: EnvConfig;
1113
+ jsc?: JscConfig;
1114
+ module?: ModuleConfig;
1115
+ minify?: boolean;
1116
+ /**
1117
+ * - true to generate a sourcemap for the code and include it in the result object.
1118
+ * - "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.
1119
+ *
1120
+ * `swc-cli` overloads some of these to also affect how maps are written to disk:
1121
+ *
1122
+ * - true will write the map to a .map file on disk
1123
+ * - "inline" will write the file directly, so it will have a data: containing the map
1124
+ * - Note: These options are bit weird, so it may make the most sense to just use true
1125
+ * and handle the rest in your own code, depending on your use case.
1126
+ */
1127
+ sourceMaps?: boolean | "inline";
1128
+ inlineSourcesContent?: boolean;
1129
+ }
1130
+ /**
1131
+ * Configuration ported from babel-preset-env
1132
+ */
1133
+ interface EnvConfig {
1134
+ mode?: "usage" | "entry";
1135
+ debug?: boolean;
1136
+ dynamicImport?: boolean;
1137
+ loose?: boolean;
1138
+ skip?: string[];
1139
+ include?: string[];
1140
+ exclude?: string[];
1141
+ /**
1142
+ * The version of the used core js.
1143
+ *
1144
+ */
1145
+ coreJs?: string;
1146
+ targets?: any;
1147
+ path?: string;
1148
+ shippedProposals?: boolean;
1149
+ /**
1150
+ * Enable all transforms
1151
+ */
1152
+ forceAllTransforms?: boolean;
1153
+ }
1154
+ interface JscConfig {
1155
+ loose?: boolean;
1156
+ /**
1157
+ * Defaults to EsParserConfig
1158
+ */
1159
+ parser?: ParserConfig;
1160
+ transform?: TransformConfig;
1161
+ /**
1162
+ * Use `@swc/helpers` instead of inline helpers.
1163
+ */
1164
+ externalHelpers?: boolean;
1165
+ /**
1166
+ * Defaults to `es3` (which enabled **all** pass).
1167
+ */
1168
+ target?: JscTarget;
1169
+ /**
1170
+ * Keep class names.
1171
+ */
1172
+ keepClassNames?: boolean;
1173
+ /**
1174
+ * This is experimental, and can be removed without a major version bump.
1175
+ */
1176
+ experimental?: {
1177
+ optimizeHygiene?: boolean;
1178
+ /**
1179
+ * Preserve `with` in imports and exports.
1180
+ */
1181
+ keepImportAttributes?: boolean;
1182
+ /**
1183
+ * Use `assert` instead of `with` for imports and exports.
1184
+ * This option only works when `keepImportAttributes` is `true`.
1185
+ */
1186
+ emitAssertForImportAttributes?: boolean;
1187
+ /**
1188
+ * Specify the location where SWC stores its intermediate cache files.
1189
+ * Currently only transform plugin uses this. If not specified, SWC will
1190
+ * create `.swc` directories.
1191
+ */
1192
+ cacheRoot?: string;
1193
+ /**
1194
+ * List of custom transform plugins written in WebAssembly.
1195
+ * First parameter of tuple indicates the name of the plugin - it can be either
1196
+ * a name of the npm package can be resolved, or absolute path to .wasm binary.
1197
+ *
1198
+ * Second parameter of tuple is JSON based configuration for the plugin.
1199
+ */
1200
+ plugins?: Array<[string, Record<string, any>]>;
1201
+ /**
1202
+ * Disable builtin transforms. If enabled, only Wasm plugins are used.
1203
+ */
1204
+ disableBuiltinTransformsForInternalTesting?: boolean;
1205
+ };
1206
+ baseUrl?: string;
1207
+ paths?: {
1208
+ [from: string]: string[];
1209
+ };
1210
+ minify?: JsMinifyOptions;
1211
+ preserveAllComments?: boolean;
1212
+ }
1213
+ type JscTarget = "es3" | "es5" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "esnext";
1214
+ type ParserConfig = TsParserConfig | EsParserConfig;
1215
+ interface TsParserConfig {
1216
+ syntax: "typescript";
1217
+ /**
1218
+ * Defaults to `false`.
1219
+ */
1220
+ tsx?: boolean;
1221
+ /**
1222
+ * Defaults to `false`.
1223
+ */
1224
+ decorators?: boolean;
1225
+ /**
1226
+ * Defaults to `false`
1227
+ */
1228
+ dynamicImport?: boolean;
1229
+ }
1230
+ interface EsParserConfig {
1231
+ syntax: "ecmascript";
1232
+ /**
1233
+ * Defaults to false.
1234
+ */
1235
+ jsx?: boolean;
1236
+ /**
1237
+ * @deprecated Always true because it's in ecmascript spec.
1238
+ */
1239
+ numericSeparator?: boolean;
1240
+ /**
1241
+ * @deprecated Always true because it's in ecmascript spec.
1242
+ */
1243
+ classPrivateProperty?: boolean;
1244
+ /**
1245
+ * @deprecated Always true because it's in ecmascript spec.
1246
+ */
1247
+ privateMethod?: boolean;
1248
+ /**
1249
+ * @deprecated Always true because it's in ecmascript spec.
1250
+ */
1251
+ classProperty?: boolean;
1252
+ /**
1253
+ * Defaults to `false`
1254
+ */
1255
+ functionBind?: boolean;
1256
+ /**
1257
+ * Defaults to `false`
1258
+ */
1259
+ decorators?: boolean;
1260
+ /**
1261
+ * Defaults to `false`
1262
+ */
1263
+ decoratorsBeforeExport?: boolean;
1264
+ /**
1265
+ * Defaults to `false`
1266
+ */
1267
+ exportDefaultFrom?: boolean;
1268
+ /**
1269
+ * @deprecated Always true because it's in ecmascript spec.
1270
+ */
1271
+ exportNamespaceFrom?: boolean;
1272
+ /**
1273
+ * @deprecated Always true because it's in ecmascript spec.
1274
+ */
1275
+ dynamicImport?: boolean;
1276
+ /**
1277
+ * @deprecated Always true because it's in ecmascript spec.
1278
+ */
1279
+ nullishCoalescing?: boolean;
1280
+ /**
1281
+ * @deprecated Always true because it's in ecmascript spec.
1282
+ */
1283
+ optionalChaining?: boolean;
1284
+ /**
1285
+ * @deprecated Always true because it's in ecmascript spec.
1286
+ */
1287
+ importMeta?: boolean;
1288
+ /**
1289
+ * @deprecated Always true because it's in ecmascript spec.
1290
+ */
1291
+ topLevelAwait?: boolean;
1292
+ /**
1293
+ * Defaults to `false`
1294
+ */
1295
+ importAssertions?: boolean;
1296
+ }
1297
+ /**
1298
+ * Options for transform.
1299
+ */
1300
+ interface TransformConfig {
1301
+ /**
1302
+ * Effective only if `syntax` supports ƒ.
1303
+ */
1304
+ react?: ReactConfig;
1305
+ constModules?: ConstModulesConfig;
1306
+ /**
1307
+ * Defaults to null, which skips optimizer pass.
1308
+ */
1309
+ optimizer?: OptimizerConfig;
1310
+ /**
1311
+ * https://swc.rs/docs/configuring-swc.html#jsctransformlegacydecorator
1312
+ */
1313
+ legacyDecorator?: boolean;
1314
+ /**
1315
+ * https://swc.rs/docs/configuring-swc.html#jsctransformdecoratormetadata
1316
+ */
1317
+ decoratorMetadata?: boolean;
1318
+ treatConstEnumAsEnum?: boolean;
1319
+ useDefineForClassFields?: boolean;
1320
+ }
1321
+ interface ReactConfig {
1322
+ /**
1323
+ * Replace the function used when compiling JSX expressions.
1324
+ *
1325
+ * Defaults to `React.createElement`.
1326
+ */
1327
+ pragma?: string;
1328
+ /**
1329
+ * Replace the component used when compiling JSX fragments.
1330
+ *
1331
+ * Defaults to `React.Fragment`
1332
+ */
1333
+ pragmaFrag?: string;
1334
+ /**
1335
+ * Toggles whether or not to throw an error if a XML namespaced tag name is used. For example:
1336
+ * `<f:image />`
1337
+ *
1338
+ * Though the JSX spec allows this, it is disabled by default since React's
1339
+ * JSX does not currently have support for it.
1340
+ *
1341
+ */
1342
+ throwIfNamespace?: boolean;
1343
+ /**
1344
+ * Toggles plugins that aid in development, such as @swc/plugin-transform-react-jsx-self
1345
+ * and @swc/plugin-transform-react-jsx-source.
1346
+ *
1347
+ * Defaults to `false`,
1348
+ *
1349
+ */
1350
+ development?: boolean;
1351
+ /**
1352
+ * Use `Object.assign()` instead of `_extends`. Defaults to false.
1353
+ * @deprecated
1354
+ */
1355
+ useBuiltins?: boolean;
1356
+ /**
1357
+ * Enable fast refresh feature for React app
1358
+ */
1359
+ refresh?: boolean;
1360
+ /**
1361
+ * jsx runtime
1362
+ */
1363
+ runtime?: "automatic" | "classic";
1364
+ /**
1365
+ * Declares the module specifier to be used for importing the `jsx` and `jsxs` factory functions when using `runtime` 'automatic'
1366
+ */
1367
+ importSource?: string;
1368
+ }
1369
+ /**
1370
+ * - `import { DEBUG } from '@ember/env-flags';`
1371
+ * - `import { FEATURE_A, FEATURE_B } from '@ember/features';`
1372
+ *
1373
+ * See: https://github.com/swc-project/swc/issues/18#issuecomment-466272558
1374
+ */
1375
+ interface ConstModulesConfig {
1376
+ globals?: {
1377
+ [module: string]: {
1378
+ [name: string]: string;
1379
+ };
1380
+ };
1381
+ }
1382
+ interface OptimizerConfig {
1383
+ simplify?: boolean;
1384
+ globals?: GlobalPassOption;
1385
+ jsonify?: {
1386
+ minCost: number;
1387
+ };
1388
+ }
1389
+ /**
1390
+ * Options for inline-global pass.
1391
+ */
1392
+ interface GlobalPassOption {
1393
+ /**
1394
+ * Global variables that should be inlined with passed value.
1395
+ *
1396
+ * e.g. `{ __DEBUG__: true }`
1397
+ */
1398
+ vars?: Record<string, string>;
1399
+ /**
1400
+ * Names of environment variables that should be inlined with the value of corresponding env during build.
1401
+ *
1402
+ * Defaults to `["NODE_ENV", "SWC_ENV"]`
1403
+ */
1404
+ envs?: string[];
1405
+ /**
1406
+ * Replaces typeof calls for passed variables with corresponding value
1407
+ *
1408
+ * e.g. `{ window: 'object' }`
1409
+ */
1410
+ typeofs?: Record<string, string>;
1411
+ }
1412
+ type ModuleConfig = Es6Config | CommonJsConfig | UmdConfig | AmdConfig | NodeNextConfig | SystemjsConfig;
1413
+ interface BaseModuleConfig {
1414
+ /**
1415
+ * By default, when using exports with babel a non-enumerable `__esModule`
1416
+ * property is exported. In some cases this property is used to determine
1417
+ * if the import is the default export or if it contains the default export.
1418
+ *
1419
+ * In order to prevent the __esModule property from being exported, you
1420
+ * can set the strict option to true.
1421
+ *
1422
+ * Defaults to `false`.
1423
+ */
1424
+ strict?: boolean;
1425
+ /**
1426
+ * Emits 'use strict' directive.
1427
+ *
1428
+ * Defaults to `true`.
1429
+ */
1430
+ strictMode?: boolean;
1431
+ /**
1432
+ * Changes Babel's compiled import statements to be lazily evaluated when their imported bindings are used for the first time.
1433
+ *
1434
+ * This can improve initial load time of your module because evaluating dependencies up
1435
+ * front is sometimes entirely un-necessary. This is especially the case when implementing
1436
+ * a library module.
1437
+ *
1438
+ *
1439
+ * The value of `lazy` has a few possible effects:
1440
+ *
1441
+ * - `false` - No lazy initialization of any imported module.
1442
+ * - `true` - Do not lazy-initialize local `./foo` imports, but lazy-init `foo` dependencies.
1443
+ *
1444
+ * Local paths are much more likely to have circular dependencies, which may break if loaded lazily,
1445
+ * so they are not lazy by default, whereas dependencies between independent modules are rarely cyclical.
1446
+ *
1447
+ * - `Array<string>` - Lazy-initialize all imports with source matching one of the given strings.
1448
+ *
1449
+ * -----
1450
+ *
1451
+ * The two cases where imports can never be lazy are:
1452
+ *
1453
+ * - `import "foo";`
1454
+ *
1455
+ * Side-effect imports are automatically non-lazy since their very existence means
1456
+ * that there is no binding to later kick off initialization.
1457
+ *
1458
+ * - `export * from "foo"`
1459
+ *
1460
+ * Re-exporting all names requires up-front execution because otherwise there is no
1461
+ * way to know what names need to be exported.
1462
+ *
1463
+ * Defaults to `false`.
1464
+ */
1465
+ lazy?: boolean | string[];
1466
+ /**
1467
+ * @deprecated Use the `importInterop` option instead.
1468
+ *
1469
+ * By default, when using exports with swc a non-enumerable __esModule property is exported.
1470
+ * This property is then used to determine if the import is the default export or if
1471
+ * it contains the default export.
1472
+ *
1473
+ * In cases where the auto-unwrapping of default is not needed, you can set the noInterop option
1474
+ * to true to avoid the usage of the interopRequireDefault helper (shown in inline form above).
1475
+ *
1476
+ * Defaults to `false`.
1477
+ */
1478
+ noInterop?: boolean;
1479
+ /**
1480
+ * Defaults to `swc`.
1481
+ *
1482
+ * CommonJS modules and ECMAScript modules are not fully compatible.
1483
+ * However, compilers, bundlers and JavaScript runtimes developed different strategies
1484
+ * to make them work together as well as possible.
1485
+ *
1486
+ * - `swc` (alias: `babel`)
1487
+ *
1488
+ * When using exports with `swc` a non-enumerable `__esModule` property is exported
1489
+ * This property is then used to determine if the import is the default export
1490
+ * or if it contains the default export.
1491
+ *
1492
+ * ```javascript
1493
+ * import foo from "foo";
1494
+ * import { bar } from "bar";
1495
+ * foo;
1496
+ * bar;
1497
+ *
1498
+ * // Is compiled to ...
1499
+ *
1500
+ * "use strict";
1501
+ *
1502
+ * function _interop_require_default(obj) {
1503
+ * return obj && obj.__esModule ? obj : { default: obj };
1504
+ * }
1505
+ *
1506
+ * var _foo = _interop_require_default(require("foo"));
1507
+ * var _bar = require("bar");
1508
+ *
1509
+ * _foo.default;
1510
+ * _bar.bar;
1511
+ * ```
1512
+ *
1513
+ * When this import interop is used, if both the imported and the importer module are compiled
1514
+ * with swc they behave as if none of them was compiled.
1515
+ *
1516
+ * This is the default behavior.
1517
+ *
1518
+ * - `node`
1519
+ *
1520
+ * When importing CommonJS files (either directly written in CommonJS, or generated with a compiler)
1521
+ * Node.js always binds the `default` export to the value of `module.exports`.
1522
+ *
1523
+ * ```javascript
1524
+ * import foo from "foo";
1525
+ * import { bar } from "bar";
1526
+ * foo;
1527
+ * bar;
1528
+ *
1529
+ * // Is compiled to ...
1530
+ *
1531
+ * "use strict";
1532
+ *
1533
+ * var _foo = require("foo");
1534
+ * var _bar = require("bar");
1535
+ *
1536
+ * _foo;
1537
+ * _bar.bar;
1538
+ * ```
1539
+ * This is not exactly the same as what Node.js does since swc allows accessing any property of `module.exports`
1540
+ * as a named export, while Node.js only allows importing statically analyzable properties of `module.exports`.
1541
+ * However, any import working in Node.js will also work when compiled with swc using `importInterop: "node"`.
1542
+ *
1543
+ * - `none`
1544
+ *
1545
+ * If you know that the imported file has been transformed with a compiler that stores the `default` export on
1546
+ * `exports.default` (such as swc or Babel), you can safely omit the `_interop_require_default` helper.
1547
+ *
1548
+ * ```javascript
1549
+ * import foo from "foo";
1550
+ * import { bar } from "bar";
1551
+ * foo;
1552
+ * bar;
1553
+ *
1554
+ * // Is compiled to ...
1555
+ *
1556
+ * "use strict";
1557
+ *
1558
+ * var _foo = require("foo");
1559
+ * var _bar = require("bar");
1560
+ *
1561
+ * _foo.default;
1562
+ * _bar.bar;
1563
+ * ```
1564
+ */
1565
+ importInterop?: "swc" | "babel" | "node" | "none";
1566
+ /**
1567
+ * Emits `cjs-module-lexer` annotation
1568
+ * `cjs-module-lexer` is used in Node.js core for detecting the named exports available when importing a CJS module into ESM.
1569
+ * swc will emit `cjs-module-lexer` detectable annotation with this option enabled.
1570
+ *
1571
+ * Defaults to `true` if import_interop is Node, else `false`
1572
+ */
1573
+ exportInteropAnnotation?: boolean;
1574
+ /**
1575
+ * If set to true, dynamic imports will be preserved.
1576
+ */
1577
+ ignoreDynamic?: boolean;
1578
+ allowTopLevelThis?: boolean;
1579
+ preserveImportMeta?: boolean;
1580
+ }
1581
+ interface Es6Config extends BaseModuleConfig {
1582
+ type: "es6";
1583
+ }
1584
+ interface NodeNextConfig extends BaseModuleConfig {
1585
+ type: "nodenext";
1586
+ }
1587
+ interface CommonJsConfig extends BaseModuleConfig {
1588
+ type: "commonjs";
1589
+ }
1590
+ interface UmdConfig extends BaseModuleConfig {
1591
+ type: "umd";
1592
+ globals?: {
1593
+ [key: string]: string;
1594
+ };
1595
+ }
1596
+ interface AmdConfig extends BaseModuleConfig {
1597
+ type: "amd";
1598
+ moduleId?: string;
1599
+ }
1600
+ interface SystemjsConfig {
1601
+ type: "systemjs";
1602
+ allowTopLevelThis?: boolean;
1603
+ }
1604
+ interface MatchPattern {
1605
+ }
1606
+ interface Span {
1607
+ start: number;
1608
+ end: number;
1609
+ ctxt: number;
1610
+ }
1611
+ interface Node {
1612
+ type: string;
1613
+ }
1614
+ interface HasSpan {
1615
+ span: Span;
1616
+ }
1617
+ interface HasDecorator {
1618
+ decorators?: Decorator[];
1619
+ }
1620
+ interface Class extends HasSpan, HasDecorator {
1621
+ body: ClassMember[];
1622
+ superClass?: Expression;
1623
+ isAbstract: boolean;
1624
+ typeParams?: TsTypeParameterDeclaration;
1625
+ superTypeParams?: TsTypeParameterInstantiation;
1626
+ implements: TsExpressionWithTypeArguments[];
1627
+ }
1628
+ type ClassMember = Constructor | ClassMethod | PrivateMethod | ClassProperty | PrivateProperty | TsIndexSignature | EmptyStatement | StaticBlock;
1629
+ interface ClassPropertyBase extends Node, HasSpan, HasDecorator {
1630
+ value?: Expression;
1631
+ typeAnnotation?: TsTypeAnnotation;
1632
+ isStatic: boolean;
1633
+ accessibility?: Accessibility;
1634
+ isOptional: boolean;
1635
+ isOverride: boolean;
1636
+ readonly: boolean;
1637
+ definite: boolean;
1638
+ }
1639
+ interface ClassProperty extends ClassPropertyBase {
1640
+ type: "ClassProperty";
1641
+ key: PropertyName;
1642
+ isAbstract: boolean;
1643
+ declare: boolean;
1644
+ }
1645
+ interface PrivateProperty extends ClassPropertyBase {
1646
+ type: "PrivateProperty";
1647
+ key: PrivateName;
1648
+ }
1649
+ interface Param extends Node, HasSpan, HasDecorator {
1650
+ type: "Parameter";
1651
+ pat: Pattern;
1652
+ }
1653
+ interface Constructor extends Node, HasSpan {
1654
+ type: "Constructor";
1655
+ key: PropertyName;
1656
+ params: (TsParameterProperty | Param)[];
1657
+ body?: BlockStatement;
1658
+ accessibility?: Accessibility;
1659
+ isOptional: boolean;
1660
+ }
1661
+ interface ClassMethodBase extends Node, HasSpan {
1662
+ function: Fn;
1663
+ kind: MethodKind;
1664
+ isStatic: boolean;
1665
+ accessibility?: Accessibility;
1666
+ isAbstract: boolean;
1667
+ isOptional: boolean;
1668
+ isOverride: boolean;
1669
+ }
1670
+ interface ClassMethod extends ClassMethodBase {
1671
+ type: "ClassMethod";
1672
+ key: PropertyName;
1673
+ }
1674
+ interface PrivateMethod extends ClassMethodBase {
1675
+ type: "PrivateMethod";
1676
+ key: PrivateName;
1677
+ }
1678
+ interface StaticBlock extends Node, HasSpan {
1679
+ type: "StaticBlock";
1680
+ body: BlockStatement;
1681
+ }
1682
+ interface Decorator extends Node, HasSpan {
1683
+ type: "Decorator";
1684
+ expression: Expression;
1685
+ }
1686
+ type MethodKind = "method" | "getter" | "setter";
1687
+ type Declaration = ClassDeclaration | FunctionDeclaration | VariableDeclaration | TsInterfaceDeclaration | TsTypeAliasDeclaration | TsEnumDeclaration | TsModuleDeclaration;
1688
+ interface FunctionDeclaration extends Fn {
1689
+ type: "FunctionDeclaration";
1690
+ identifier: Identifier;
1691
+ declare: boolean;
1692
+ }
1693
+ interface ClassDeclaration extends Class, Node {
1694
+ type: "ClassDeclaration";
1695
+ identifier: Identifier;
1696
+ declare: boolean;
1697
+ }
1698
+ interface VariableDeclaration extends Node, HasSpan {
1699
+ type: "VariableDeclaration";
1700
+ kind: VariableDeclarationKind;
1701
+ declare: boolean;
1702
+ declarations: VariableDeclarator[];
1703
+ }
1704
+ type VariableDeclarationKind = "var" | "let" | "const";
1705
+ interface VariableDeclarator extends Node, HasSpan {
1706
+ type: "VariableDeclarator";
1707
+ id: Pattern;
1708
+ init?: Expression;
1709
+ definite: boolean;
1710
+ }
1711
+ type Expression = ThisExpression | ArrayExpression | ObjectExpression | FunctionExpression | UnaryExpression | UpdateExpression | BinaryExpression | AssignmentExpression | MemberExpression | SuperPropExpression | ConditionalExpression | CallExpression | NewExpression | SequenceExpression | Identifier | Literal | TemplateLiteral | TaggedTemplateExpression | ArrowFunctionExpression | ClassExpression | YieldExpression | MetaProperty | AwaitExpression | ParenthesisExpression | JSXMemberExpression | JSXNamespacedName | JSXEmptyExpression | JSXElement | JSXFragment | TsTypeAssertion | TsConstAssertion | TsNonNullExpression | TsAsExpression | TsSatisfiesExpression | TsInstantiation | PrivateName | OptionalChainingExpression | Invalid;
1712
+ interface ExpressionBase extends Node, HasSpan {
1713
+ }
1714
+ interface Identifier extends ExpressionBase {
1715
+ type: "Identifier";
1716
+ value: string;
1717
+ optional: boolean;
1718
+ }
1719
+ interface OptionalChainingExpression extends ExpressionBase {
1720
+ type: "OptionalChainingExpression";
1721
+ questionDotToken: Span;
1722
+ /**
1723
+ * Call expression or member expression.
1724
+ */
1725
+ base: MemberExpression | OptionalChainingCall;
1726
+ }
1727
+ interface OptionalChainingCall extends ExpressionBase {
1728
+ type: "CallExpression";
1729
+ callee: Expression;
1730
+ arguments: ExprOrSpread[];
1731
+ typeArguments?: TsTypeParameterInstantiation;
1732
+ }
1733
+ interface ThisExpression extends ExpressionBase {
1734
+ type: "ThisExpression";
1735
+ }
1736
+ interface ArrayExpression extends ExpressionBase {
1737
+ type: "ArrayExpression";
1738
+ elements: (ExprOrSpread | undefined)[];
1739
+ }
1740
+ interface ExprOrSpread {
1741
+ spread?: Span;
1742
+ expression: Expression;
1743
+ }
1744
+ interface ObjectExpression extends ExpressionBase {
1745
+ type: "ObjectExpression";
1746
+ properties: (SpreadElement | Property)[];
1747
+ }
1748
+ interface Argument {
1749
+ spread?: Span;
1750
+ expression: Expression;
1751
+ }
1752
+ interface SpreadElement extends Node {
1753
+ type: "SpreadElement";
1754
+ spread: Span;
1755
+ arguments: Expression;
1756
+ }
1757
+ interface UnaryExpression extends ExpressionBase {
1758
+ type: "UnaryExpression";
1759
+ operator: UnaryOperator;
1760
+ argument: Expression;
1761
+ }
1762
+ interface UpdateExpression extends ExpressionBase {
1763
+ type: "UpdateExpression";
1764
+ operator: UpdateOperator;
1765
+ prefix: boolean;
1766
+ argument: Expression;
1767
+ }
1768
+ interface BinaryExpression extends ExpressionBase {
1769
+ type: "BinaryExpression";
1770
+ operator: BinaryOperator;
1771
+ left: Expression;
1772
+ right: Expression;
1773
+ }
1774
+ interface FunctionExpression extends Fn, ExpressionBase {
1775
+ type: "FunctionExpression";
1776
+ identifier?: Identifier;
1777
+ }
1778
+ interface ClassExpression extends Class, ExpressionBase {
1779
+ type: "ClassExpression";
1780
+ identifier?: Identifier;
1781
+ }
1782
+ interface AssignmentExpression extends ExpressionBase {
1783
+ type: "AssignmentExpression";
1784
+ operator: AssignmentOperator;
1785
+ left: Expression | Pattern;
1786
+ right: Expression;
1787
+ }
1788
+ interface MemberExpression extends ExpressionBase {
1789
+ type: "MemberExpression";
1790
+ object: Expression;
1791
+ property: Identifier | PrivateName | ComputedPropName;
1792
+ }
1793
+ interface SuperPropExpression extends ExpressionBase {
1794
+ type: "SuperPropExpression";
1795
+ obj: Super;
1796
+ property: Identifier | ComputedPropName;
1797
+ }
1798
+ interface ConditionalExpression extends ExpressionBase {
1799
+ type: "ConditionalExpression";
1800
+ test: Expression;
1801
+ consequent: Expression;
1802
+ alternate: Expression;
1803
+ }
1804
+ interface Super extends Node, HasSpan {
1805
+ type: "Super";
1806
+ }
1807
+ interface Import extends Node, HasSpan {
1808
+ type: "Import";
1809
+ }
1810
+ interface CallExpression extends ExpressionBase {
1811
+ type: "CallExpression";
1812
+ callee: Super | Import | Expression;
1813
+ arguments: Argument[];
1814
+ typeArguments?: TsTypeParameterInstantiation;
1815
+ }
1816
+ interface NewExpression extends ExpressionBase {
1817
+ type: "NewExpression";
1818
+ callee: Expression;
1819
+ arguments?: Argument[];
1820
+ typeArguments?: TsTypeParameterInstantiation;
1821
+ }
1822
+ interface SequenceExpression extends ExpressionBase {
1823
+ type: "SequenceExpression";
1824
+ expressions: Expression[];
1825
+ }
1826
+ interface ArrowFunctionExpression extends ExpressionBase {
1827
+ type: "ArrowFunctionExpression";
1828
+ params: Pattern[];
1829
+ body: BlockStatement | Expression;
1830
+ async: boolean;
1831
+ generator: boolean;
1832
+ typeParameters?: TsTypeParameterDeclaration;
1833
+ returnType?: TsTypeAnnotation;
1834
+ }
1835
+ interface YieldExpression extends ExpressionBase {
1836
+ type: "YieldExpression";
1837
+ argument?: Expression;
1838
+ delegate: boolean;
1839
+ }
1840
+ interface MetaProperty extends Node, HasSpan {
1841
+ type: "MetaProperty";
1842
+ kind: "new.target" | "import.meta";
1843
+ }
1844
+ interface AwaitExpression extends ExpressionBase {
1845
+ type: "AwaitExpression";
1846
+ argument: Expression;
1847
+ }
1848
+ interface TemplateLiteral extends ExpressionBase {
1849
+ type: "TemplateLiteral";
1850
+ expressions: Expression[];
1851
+ quasis: TemplateElement[];
1852
+ }
1853
+ interface TaggedTemplateExpression extends ExpressionBase {
1854
+ type: "TaggedTemplateExpression";
1855
+ tag: Expression;
1856
+ typeParameters?: TsTypeParameterInstantiation;
1857
+ template: TemplateLiteral;
1858
+ }
1859
+ interface TemplateElement extends ExpressionBase {
1860
+ type: "TemplateElement";
1861
+ tail: boolean;
1862
+ cooked?: string;
1863
+ raw: string;
1864
+ }
1865
+ interface ParenthesisExpression extends ExpressionBase {
1866
+ type: "ParenthesisExpression";
1867
+ expression: Expression;
1868
+ }
1869
+ interface Fn extends HasSpan, HasDecorator {
1870
+ params: Param[];
1871
+ body?: BlockStatement;
1872
+ generator: boolean;
1873
+ async: boolean;
1874
+ typeParameters?: TsTypeParameterDeclaration;
1875
+ returnType?: TsTypeAnnotation;
1876
+ }
1877
+ interface PatternBase extends Node, HasSpan {
1878
+ typeAnnotation?: TsTypeAnnotation;
1879
+ }
1880
+ interface PrivateName extends ExpressionBase {
1881
+ type: "PrivateName";
1882
+ id: Identifier;
1883
+ }
1884
+ type JSXObject = JSXMemberExpression | Identifier;
1885
+ interface JSXMemberExpression extends Node {
1886
+ type: "JSXMemberExpression";
1887
+ object: JSXObject;
1888
+ property: Identifier;
1889
+ }
1890
+ /**
1891
+ * XML-based namespace syntax:
1892
+ */
1893
+ interface JSXNamespacedName extends Node {
1894
+ type: "JSXNamespacedName";
1895
+ namespace: Identifier;
1896
+ name: Identifier;
1897
+ }
1898
+ interface JSXEmptyExpression extends Node, HasSpan {
1899
+ type: "JSXEmptyExpression";
1900
+ }
1901
+ interface JSXExpressionContainer extends Node, HasSpan {
1902
+ type: "JSXExpressionContainer";
1903
+ expression: JSXExpression;
1904
+ }
1905
+ type JSXExpression = JSXEmptyExpression | Expression;
1906
+ interface JSXSpreadChild extends Node, HasSpan {
1907
+ type: "JSXSpreadChild";
1908
+ expression: Expression;
1909
+ }
1910
+ type JSXElementName = Identifier | JSXMemberExpression | JSXNamespacedName;
1911
+ interface JSXOpeningElement extends Node, HasSpan {
1912
+ type: "JSXOpeningElement";
1913
+ name: JSXElementName;
1914
+ attributes: JSXAttributeOrSpread[];
1915
+ selfClosing: boolean;
1916
+ typeArguments?: TsTypeParameterInstantiation;
1917
+ }
1918
+ type JSXAttributeOrSpread = JSXAttribute | SpreadElement;
1919
+ interface JSXClosingElement extends Node, HasSpan {
1920
+ type: "JSXClosingElement";
1921
+ name: JSXElementName;
1922
+ }
1923
+ interface JSXAttribute extends Node, HasSpan {
1924
+ type: "JSXAttribute";
1925
+ name: JSXAttributeName;
1926
+ value?: JSXAttrValue;
1927
+ }
1928
+ type JSXAttributeName = Identifier | JSXNamespacedName;
1929
+ type JSXAttrValue = Literal | JSXExpressionContainer | JSXElement | JSXFragment;
1930
+ interface JSXText extends Node, HasSpan {
1931
+ type: "JSXText";
1932
+ value: string;
1933
+ raw: string;
1934
+ }
1935
+ interface JSXElement extends Node, HasSpan {
1936
+ type: "JSXElement";
1937
+ opening: JSXOpeningElement;
1938
+ children: JSXElementChild[];
1939
+ closing?: JSXClosingElement;
1940
+ }
1941
+ type JSXElementChild = JSXText | JSXExpressionContainer | JSXSpreadChild | JSXElement | JSXFragment;
1942
+ interface JSXFragment extends Node, HasSpan {
1943
+ type: "JSXFragment";
1944
+ opening: JSXOpeningFragment;
1945
+ children: JSXElementChild[];
1946
+ closing: JSXClosingFragment;
1947
+ }
1948
+ interface JSXOpeningFragment extends Node, HasSpan {
1949
+ type: "JSXOpeningFragment";
1950
+ }
1951
+ interface JSXClosingFragment extends Node, HasSpan {
1952
+ type: "JSXClosingFragment";
1953
+ }
1954
+ type Literal = StringLiteral | BooleanLiteral | NullLiteral | NumericLiteral | BigIntLiteral | RegExpLiteral | JSXText;
1955
+ interface StringLiteral extends Node, HasSpan {
1956
+ type: "StringLiteral";
1957
+ value: string;
1958
+ raw?: string;
1959
+ }
1960
+ interface BooleanLiteral extends Node, HasSpan {
1961
+ type: "BooleanLiteral";
1962
+ value: boolean;
1963
+ }
1964
+ interface NullLiteral extends Node, HasSpan {
1965
+ type: "NullLiteral";
1966
+ }
1967
+ interface RegExpLiteral extends Node, HasSpan {
1968
+ type: "RegExpLiteral";
1969
+ pattern: string;
1970
+ flags: string;
1971
+ }
1972
+ interface NumericLiteral extends Node, HasSpan {
1973
+ type: "NumericLiteral";
1974
+ value: number;
1975
+ raw?: string;
1976
+ }
1977
+ interface BigIntLiteral extends Node, HasSpan {
1978
+ type: "BigIntLiteral";
1979
+ value: bigint;
1980
+ raw?: string;
1981
+ }
1982
+ type ModuleDeclaration = ImportDeclaration | ExportDeclaration | ExportNamedDeclaration | ExportDefaultDeclaration | ExportDefaultExpression | ExportAllDeclaration | TsImportEqualsDeclaration | TsExportAssignment | TsNamespaceExportDeclaration;
1983
+ interface ExportDefaultExpression extends Node, HasSpan {
1984
+ type: "ExportDefaultExpression";
1985
+ expression: Expression;
1986
+ }
1987
+ interface ExportDeclaration extends Node, HasSpan {
1988
+ type: "ExportDeclaration";
1989
+ declaration: Declaration;
1990
+ }
1991
+ interface ImportDeclaration extends Node, HasSpan {
1992
+ type: "ImportDeclaration";
1993
+ specifiers: ImportSpecifier[];
1994
+ source: StringLiteral;
1995
+ typeOnly: boolean;
1996
+ asserts?: ObjectExpression;
1997
+ }
1998
+ interface ExportAllDeclaration extends Node, HasSpan {
1999
+ type: "ExportAllDeclaration";
2000
+ source: StringLiteral;
2001
+ asserts?: ObjectExpression;
2002
+ }
2003
+ /**
2004
+ * - `export { foo } from 'mod'`
2005
+ * - `export { foo as bar } from 'mod'`
2006
+ */
2007
+ interface ExportNamedDeclaration extends Node, HasSpan {
2008
+ type: "ExportNamedDeclaration";
2009
+ specifiers: ExportSpecifier[];
2010
+ source?: StringLiteral;
2011
+ typeOnly: boolean;
2012
+ asserts?: ObjectExpression;
2013
+ }
2014
+ interface ExportDefaultDeclaration extends Node, HasSpan {
2015
+ type: "ExportDefaultDeclaration";
2016
+ decl: DefaultDecl;
2017
+ }
2018
+ type DefaultDecl = ClassExpression | FunctionExpression | TsInterfaceDeclaration;
2019
+ type ImportSpecifier = NamedImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier;
2020
+ /**
2021
+ * e.g. `import foo from 'mod.js'`
2022
+ */
2023
+ interface ImportDefaultSpecifier extends Node, HasSpan {
2024
+ type: "ImportDefaultSpecifier";
2025
+ local: Identifier;
2026
+ }
2027
+ /**
2028
+ * e.g. `import * as foo from 'mod.js'`.
2029
+ */
2030
+ interface ImportNamespaceSpecifier extends Node, HasSpan {
2031
+ type: "ImportNamespaceSpecifier";
2032
+ local: Identifier;
2033
+ }
2034
+ /**
2035
+ * e.g. - `import { foo } from 'mod.js'`
2036
+ *
2037
+ * local = foo, imported = None
2038
+ *
2039
+ * e.g. `import { foo as bar } from 'mod.js'`
2040
+ *
2041
+ * local = bar, imported = Some(foo) for
2042
+ */
2043
+ interface NamedImportSpecifier extends Node, HasSpan {
2044
+ type: "ImportSpecifier";
2045
+ local: Identifier;
2046
+ imported?: ModuleExportName;
2047
+ isTypeOnly: boolean;
2048
+ }
2049
+ type ModuleExportName = Identifier | StringLiteral;
2050
+ type ExportSpecifier = ExportNamespaceSpecifier | ExportDefaultSpecifier | NamedExportSpecifier;
2051
+ /**
2052
+ * `export * as foo from 'src';`
2053
+ */
2054
+ interface ExportNamespaceSpecifier extends Node, HasSpan {
2055
+ type: "ExportNamespaceSpecifier";
2056
+ name: ModuleExportName;
2057
+ }
2058
+ interface ExportDefaultSpecifier extends Node, HasSpan {
2059
+ type: "ExportDefaultSpecifier";
2060
+ exported: Identifier;
2061
+ }
2062
+ interface NamedExportSpecifier extends Node, HasSpan {
2063
+ type: "ExportSpecifier";
2064
+ orig: ModuleExportName;
2065
+ /**
2066
+ * `Some(bar)` in `export { foo as bar }`
2067
+ */
2068
+ exported?: ModuleExportName;
2069
+ isTypeOnly: boolean;
2070
+ }
2071
+ interface HasInterpreter {
2072
+ /**
2073
+ * e.g. `/usr/bin/node` for `#!/usr/bin/node`
2074
+ */
2075
+ interpreter: string;
2076
+ }
2077
+ type Program = Module | Script;
2078
+ interface Module extends Node, HasSpan, HasInterpreter {
2079
+ type: "Module";
2080
+ body: ModuleItem[];
2081
+ }
2082
+ interface Script extends Node, HasSpan, HasInterpreter {
2083
+ type: "Script";
2084
+ body: Statement[];
2085
+ }
2086
+ type ModuleItem = ModuleDeclaration | Statement;
2087
+ type BinaryOperator = "==" | "!=" | "===" | "!==" | "<" | "<=" | ">" | ">=" | "<<" | ">>" | ">>>" | "+" | "-" | "*" | "/" | "%" | "|" | "^" | "&" | "||" | "&&" | "in" | "instanceof" | "**" | "??";
2088
+ type AssignmentOperator = "=" | "+=" | "-=" | "*=" | "/=" | "%=" | "<<=" | ">>=" | ">>>=" | "|=" | "^=" | "&=" | "**=" | "&&=" | "||=" | "??=";
2089
+ type UpdateOperator = "++" | "--";
2090
+ type UnaryOperator = "-" | "+" | "!" | "~" | "typeof" | "void" | "delete";
2091
+ type Pattern = BindingIdentifier | ArrayPattern | RestElement | ObjectPattern | AssignmentPattern | Invalid | Expression;
2092
+ interface BindingIdentifier extends PatternBase {
2093
+ type: "Identifier";
2094
+ value: string;
2095
+ optional: boolean;
2096
+ }
2097
+ interface ArrayPattern extends PatternBase {
2098
+ type: "ArrayPattern";
2099
+ elements: (Pattern | undefined)[];
2100
+ optional: boolean;
2101
+ }
2102
+ interface ObjectPattern extends PatternBase {
2103
+ type: "ObjectPattern";
2104
+ properties: ObjectPatternProperty[];
2105
+ optional: boolean;
2106
+ }
2107
+ interface AssignmentPattern extends PatternBase {
2108
+ type: "AssignmentPattern";
2109
+ left: Pattern;
2110
+ right: Expression;
2111
+ }
2112
+ interface RestElement extends PatternBase {
2113
+ type: "RestElement";
2114
+ rest: Span;
2115
+ argument: Pattern;
2116
+ }
2117
+ type ObjectPatternProperty = KeyValuePatternProperty | AssignmentPatternProperty | RestElement;
2118
+ /**
2119
+ * `{key: value}`
2120
+ */
2121
+ interface KeyValuePatternProperty extends Node {
2122
+ type: "KeyValuePatternProperty";
2123
+ key: PropertyName;
2124
+ value: Pattern;
2125
+ }
2126
+ /**
2127
+ * `{key}` or `{key = value}`
2128
+ */
2129
+ interface AssignmentPatternProperty extends Node, HasSpan {
2130
+ type: "AssignmentPatternProperty";
2131
+ key: Identifier;
2132
+ value?: Expression;
2133
+ }
2134
+ /** Identifier is `a` in `{ a, }` */
2135
+ type Property = Identifier | KeyValueProperty | AssignmentProperty | GetterProperty | SetterProperty | MethodProperty;
2136
+ interface PropBase extends Node {
2137
+ key: PropertyName;
2138
+ }
2139
+ interface KeyValueProperty extends PropBase {
2140
+ type: "KeyValueProperty";
2141
+ value: Expression;
2142
+ }
2143
+ interface AssignmentProperty extends Node {
2144
+ type: "AssignmentProperty";
2145
+ key: Identifier;
2146
+ value: Expression;
2147
+ }
2148
+ interface GetterProperty extends PropBase, HasSpan {
2149
+ type: "GetterProperty";
2150
+ typeAnnotation?: TsTypeAnnotation;
2151
+ body?: BlockStatement;
2152
+ }
2153
+ interface SetterProperty extends PropBase, HasSpan {
2154
+ type: "SetterProperty";
2155
+ param: Pattern;
2156
+ body?: BlockStatement;
2157
+ }
2158
+ interface MethodProperty extends PropBase, Fn {
2159
+ type: "MethodProperty";
2160
+ }
2161
+ type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropName | BigIntLiteral;
2162
+ interface ComputedPropName extends Node, HasSpan {
2163
+ type: "Computed";
2164
+ expression: Expression;
2165
+ }
2166
+ interface BlockStatement extends Node, HasSpan {
2167
+ type: "BlockStatement";
2168
+ stmts: Statement[];
2169
+ }
2170
+ interface ExpressionStatement extends Node, HasSpan {
2171
+ type: "ExpressionStatement";
2172
+ expression: Expression;
2173
+ }
2174
+ type Statement = BlockStatement | EmptyStatement | DebuggerStatement | WithStatement | ReturnStatement | LabeledStatement | BreakStatement | ContinueStatement | IfStatement | SwitchStatement | ThrowStatement | TryStatement | WhileStatement | DoWhileStatement | ForStatement | ForInStatement | ForOfStatement | Declaration | ExpressionStatement;
2175
+ interface EmptyStatement extends Node, HasSpan {
2176
+ type: "EmptyStatement";
2177
+ }
2178
+ interface DebuggerStatement extends Node, HasSpan {
2179
+ type: "DebuggerStatement";
2180
+ }
2181
+ interface WithStatement extends Node, HasSpan {
2182
+ type: "WithStatement";
2183
+ object: Expression;
2184
+ body: Statement;
2185
+ }
2186
+ interface ReturnStatement extends Node, HasSpan {
2187
+ type: "ReturnStatement";
2188
+ argument?: Expression;
2189
+ }
2190
+ interface LabeledStatement extends Node, HasSpan {
2191
+ type: "LabeledStatement";
2192
+ label: Identifier;
2193
+ body: Statement;
2194
+ }
2195
+ interface BreakStatement extends Node, HasSpan {
2196
+ type: "BreakStatement";
2197
+ label?: Identifier;
2198
+ }
2199
+ interface ContinueStatement extends Node, HasSpan {
2200
+ type: "ContinueStatement";
2201
+ label?: Identifier;
2202
+ }
2203
+ interface IfStatement extends Node, HasSpan {
2204
+ type: "IfStatement";
2205
+ test: Expression;
2206
+ consequent: Statement;
2207
+ alternate?: Statement;
2208
+ }
2209
+ interface SwitchStatement extends Node, HasSpan {
2210
+ type: "SwitchStatement";
2211
+ discriminant: Expression;
2212
+ cases: SwitchCase[];
2213
+ }
2214
+ interface ThrowStatement extends Node, HasSpan {
2215
+ type: "ThrowStatement";
2216
+ argument: Expression;
2217
+ }
2218
+ interface TryStatement extends Node, HasSpan {
2219
+ type: "TryStatement";
2220
+ block: BlockStatement;
2221
+ handler?: CatchClause;
2222
+ finalizer?: BlockStatement;
2223
+ }
2224
+ interface WhileStatement extends Node, HasSpan {
2225
+ type: "WhileStatement";
2226
+ test: Expression;
2227
+ body: Statement;
2228
+ }
2229
+ interface DoWhileStatement extends Node, HasSpan {
2230
+ type: "DoWhileStatement";
2231
+ test: Expression;
2232
+ body: Statement;
2233
+ }
2234
+ interface ForStatement extends Node, HasSpan {
2235
+ type: "ForStatement";
2236
+ init?: VariableDeclaration | Expression;
2237
+ test?: Expression;
2238
+ update?: Expression;
2239
+ body: Statement;
2240
+ }
2241
+ interface ForInStatement extends Node, HasSpan {
2242
+ type: "ForInStatement";
2243
+ left: VariableDeclaration | Pattern;
2244
+ right: Expression;
2245
+ body: Statement;
2246
+ }
2247
+ interface ForOfStatement extends Node, HasSpan {
2248
+ type: "ForOfStatement";
2249
+ /**
2250
+ * Span of the await token.
2251
+ *
2252
+ * es2018 for-await-of statements, e.g., `for await (const x of xs) {`
2253
+ */
2254
+ await?: Span;
2255
+ left: VariableDeclaration | Pattern;
2256
+ right: Expression;
2257
+ body: Statement;
2258
+ }
2259
+ interface SwitchCase extends Node, HasSpan {
2260
+ type: "SwitchCase";
2261
+ /**
2262
+ * Undefined for default case
2263
+ */
2264
+ test?: Expression;
2265
+ consequent: Statement[];
2266
+ }
2267
+ interface CatchClause extends Node, HasSpan {
2268
+ type: "CatchClause";
2269
+ /**
2270
+ * The param is `undefined` if the catch binding is omitted. E.g., `try { foo() } catch {}`
2271
+ */
2272
+ param?: Pattern;
2273
+ body: BlockStatement;
2274
+ }
2275
+ interface TsTypeAnnotation extends Node, HasSpan {
2276
+ type: "TsTypeAnnotation";
2277
+ typeAnnotation: TsType;
2278
+ }
2279
+ interface TsTypeParameterDeclaration extends Node, HasSpan {
2280
+ type: "TsTypeParameterDeclaration";
2281
+ parameters: TsTypeParameter[];
2282
+ }
2283
+ interface TsTypeParameter extends Node, HasSpan {
2284
+ type: "TsTypeParameter";
2285
+ name: Identifier;
2286
+ in: boolean;
2287
+ out: boolean;
2288
+ constraint?: TsType;
2289
+ default?: TsType;
2290
+ }
2291
+ interface TsTypeParameterInstantiation extends Node, HasSpan {
2292
+ type: "TsTypeParameterInstantiation";
2293
+ params: TsType[];
2294
+ }
2295
+ interface TsParameterProperty extends Node, HasSpan, HasDecorator {
2296
+ type: "TsParameterProperty";
2297
+ accessibility?: Accessibility;
2298
+ override: boolean;
2299
+ readonly: boolean;
2300
+ param: TsParameterPropertyParameter;
2301
+ }
2302
+ type TsParameterPropertyParameter = BindingIdentifier | AssignmentPattern;
2303
+ interface TsQualifiedName extends Node {
2304
+ type: "TsQualifiedName";
2305
+ left: TsEntityName;
2306
+ right: Identifier;
2307
+ }
2308
+ type TsEntityName = TsQualifiedName | Identifier;
2309
+ type TsTypeElement = TsCallSignatureDeclaration | TsConstructSignatureDeclaration | TsPropertySignature | TsGetterSignature | TsSetterSignature | TsMethodSignature | TsIndexSignature;
2310
+ interface TsCallSignatureDeclaration extends Node, HasSpan {
2311
+ type: "TsCallSignatureDeclaration";
2312
+ params: TsFnParameter[];
2313
+ typeAnnotation?: TsTypeAnnotation;
2314
+ typeParams?: TsTypeParameterDeclaration;
2315
+ }
2316
+ interface TsConstructSignatureDeclaration extends Node, HasSpan {
2317
+ type: "TsConstructSignatureDeclaration";
2318
+ params: TsFnParameter[];
2319
+ typeAnnotation?: TsTypeAnnotation;
2320
+ typeParams?: TsTypeParameterDeclaration;
2321
+ }
2322
+ interface TsPropertySignature extends Node, HasSpan {
2323
+ type: "TsPropertySignature";
2324
+ readonly: boolean;
2325
+ key: Expression;
2326
+ computed: boolean;
2327
+ optional: boolean;
2328
+ init?: Expression;
2329
+ params: TsFnParameter[];
2330
+ typeAnnotation?: TsTypeAnnotation;
2331
+ typeParams?: TsTypeParameterDeclaration;
2332
+ }
2333
+ interface TsGetterSignature extends Node, HasSpan {
2334
+ type: "TsGetterSignature";
2335
+ readonly: boolean;
2336
+ key: Expression;
2337
+ computed: boolean;
2338
+ optional: boolean;
2339
+ typeAnnotation?: TsTypeAnnotation;
2340
+ }
2341
+ interface TsSetterSignature extends Node, HasSpan {
2342
+ type: "TsSetterSignature";
2343
+ readonly: boolean;
2344
+ key: Expression;
2345
+ computed: boolean;
2346
+ optional: boolean;
2347
+ param: TsFnParameter;
2348
+ }
2349
+ interface TsMethodSignature extends Node, HasSpan {
2350
+ type: "TsMethodSignature";
2351
+ readonly: boolean;
2352
+ key: Expression;
2353
+ computed: boolean;
2354
+ optional: boolean;
2355
+ params: TsFnParameter[];
2356
+ typeAnn?: TsTypeAnnotation;
2357
+ typeParams?: TsTypeParameterDeclaration;
2358
+ }
2359
+ interface TsIndexSignature extends Node, HasSpan {
2360
+ type: "TsIndexSignature";
2361
+ params: TsFnParameter[];
2362
+ typeAnnotation?: TsTypeAnnotation;
2363
+ readonly: boolean;
2364
+ static: boolean;
2365
+ }
2366
+ type TsType = TsKeywordType | TsThisType | TsFnOrConstructorType | TsTypeReference | TsTypeQuery | TsTypeLiteral | TsArrayType | TsTupleType | TsOptionalType | TsRestType | TsUnionOrIntersectionType | TsConditionalType | TsInferType | TsParenthesizedType | TsTypeOperator | TsIndexedAccessType | TsMappedType | TsLiteralType | TsTypePredicate | TsImportType;
2367
+ type TsFnOrConstructorType = TsFunctionType | TsConstructorType;
2368
+ interface TsKeywordType extends Node, HasSpan {
2369
+ type: "TsKeywordType";
2370
+ kind: TsKeywordTypeKind;
2371
+ }
2372
+ type TsKeywordTypeKind = "any" | "unknown" | "number" | "object" | "boolean" | "bigint" | "string" | "symbol" | "void" | "undefined" | "null" | "never" | "intrinsic";
2373
+ interface TsThisType extends Node, HasSpan {
2374
+ type: "TsThisType";
2375
+ }
2376
+ type TsFnParameter = BindingIdentifier | ArrayPattern | RestElement | ObjectPattern;
2377
+ interface TsFunctionType extends Node, HasSpan {
2378
+ type: "TsFunctionType";
2379
+ params: TsFnParameter[];
2380
+ typeParams?: TsTypeParameterDeclaration;
2381
+ typeAnnotation: TsTypeAnnotation;
2382
+ }
2383
+ interface TsConstructorType extends Node, HasSpan {
2384
+ type: "TsConstructorType";
2385
+ params: TsFnParameter[];
2386
+ typeParams?: TsTypeParameterDeclaration;
2387
+ typeAnnotation: TsTypeAnnotation;
2388
+ isAbstract: boolean;
2389
+ }
2390
+ interface TsTypeReference extends Node, HasSpan {
2391
+ type: "TsTypeReference";
2392
+ typeName: TsEntityName;
2393
+ typeParams?: TsTypeParameterInstantiation;
2394
+ }
2395
+ interface TsTypePredicate extends Node, HasSpan {
2396
+ type: "TsTypePredicate";
2397
+ asserts: boolean;
2398
+ paramName: TsThisTypeOrIdent;
2399
+ typeAnnotation?: TsTypeAnnotation;
2400
+ }
2401
+ type TsThisTypeOrIdent = TsThisType | Identifier;
2402
+ interface TsImportType extends Node, HasSpan {
2403
+ type: "TsImportType";
2404
+ argument: StringLiteral;
2405
+ qualifier?: TsEntityName;
2406
+ typeArguments?: TsTypeParameterInstantiation;
2407
+ }
2408
+ /**
2409
+ * `typeof` operator
2410
+ */
2411
+ interface TsTypeQuery extends Node, HasSpan {
2412
+ type: "TsTypeQuery";
2413
+ exprName: TsTypeQueryExpr;
2414
+ typeArguments?: TsTypeParameterInstantiation;
2415
+ }
2416
+ type TsTypeQueryExpr = TsEntityName | TsImportType;
2417
+ interface TsTypeLiteral extends Node, HasSpan {
2418
+ type: "TsTypeLiteral";
2419
+ members: TsTypeElement[];
2420
+ }
2421
+ interface TsArrayType extends Node, HasSpan {
2422
+ type: "TsArrayType";
2423
+ elemType: TsType;
2424
+ }
2425
+ interface TsTupleType extends Node, HasSpan {
2426
+ type: "TsTupleType";
2427
+ elemTypes: TsTupleElement[];
2428
+ }
2429
+ interface TsTupleElement extends Node, HasSpan {
2430
+ type: "TsTupleElement";
2431
+ label?: Pattern;
2432
+ ty: TsType;
2433
+ }
2434
+ interface TsOptionalType extends Node, HasSpan {
2435
+ type: "TsOptionalType";
2436
+ typeAnnotation: TsType;
2437
+ }
2438
+ interface TsRestType extends Node, HasSpan {
2439
+ type: "TsRestType";
2440
+ typeAnnotation: TsType;
2441
+ }
2442
+ type TsUnionOrIntersectionType = TsUnionType | TsIntersectionType;
2443
+ interface TsUnionType extends Node, HasSpan {
2444
+ type: "TsUnionType";
2445
+ types: TsType[];
2446
+ }
2447
+ interface TsIntersectionType extends Node, HasSpan {
2448
+ type: "TsIntersectionType";
2449
+ types: TsType[];
2450
+ }
2451
+ interface TsConditionalType extends Node, HasSpan {
2452
+ type: "TsConditionalType";
2453
+ checkType: TsType;
2454
+ extendsType: TsType;
2455
+ trueType: TsType;
2456
+ falseType: TsType;
2457
+ }
2458
+ interface TsInferType extends Node, HasSpan {
2459
+ type: "TsInferType";
2460
+ typeParam: TsTypeParameter;
2461
+ }
2462
+ interface TsParenthesizedType extends Node, HasSpan {
2463
+ type: "TsParenthesizedType";
2464
+ typeAnnotation: TsType;
2465
+ }
2466
+ interface TsTypeOperator extends Node, HasSpan {
2467
+ type: "TsTypeOperator";
2468
+ op: TsTypeOperatorOp;
2469
+ typeAnnotation: TsType;
2470
+ }
2471
+ type TsTypeOperatorOp = "keyof" | "unique" | "readonly";
2472
+ interface TsIndexedAccessType extends Node, HasSpan {
2473
+ type: "TsIndexedAccessType";
2474
+ readonly: boolean;
2475
+ objectType: TsType;
2476
+ indexType: TsType;
2477
+ }
2478
+ type TruePlusMinus = true | "+" | "-";
2479
+ interface TsMappedType extends Node, HasSpan {
2480
+ type: "TsMappedType";
2481
+ readonly?: TruePlusMinus;
2482
+ typeParam: TsTypeParameter;
2483
+ nameType?: TsType;
2484
+ optional?: TruePlusMinus;
2485
+ typeAnnotation?: TsType;
2486
+ }
2487
+ interface TsLiteralType extends Node, HasSpan {
2488
+ type: "TsLiteralType";
2489
+ literal: TsLiteral;
2490
+ }
2491
+ type TsLiteral = NumericLiteral | StringLiteral | BooleanLiteral | BigIntLiteral | TsTemplateLiteralType;
2492
+ interface TsTemplateLiteralType extends Node, HasSpan {
2493
+ type: "TemplateLiteral";
2494
+ types: TsType[];
2495
+ quasis: TemplateElement[];
2496
+ }
2497
+ interface TsInterfaceDeclaration extends Node, HasSpan {
2498
+ type: "TsInterfaceDeclaration";
2499
+ id: Identifier;
2500
+ declare: boolean;
2501
+ typeParams?: TsTypeParameterDeclaration;
2502
+ extends: TsExpressionWithTypeArguments[];
2503
+ body: TsInterfaceBody;
2504
+ }
2505
+ interface TsInterfaceBody extends Node, HasSpan {
2506
+ type: "TsInterfaceBody";
2507
+ body: TsTypeElement[];
2508
+ }
2509
+ interface TsExpressionWithTypeArguments extends Node, HasSpan {
2510
+ type: "TsExpressionWithTypeArguments";
2511
+ expression: Expression;
2512
+ typeArguments?: TsTypeParameterInstantiation;
2513
+ }
2514
+ interface TsTypeAliasDeclaration extends Node, HasSpan {
2515
+ type: "TsTypeAliasDeclaration";
2516
+ declare: boolean;
2517
+ id: Identifier;
2518
+ typeParams?: TsTypeParameterDeclaration;
2519
+ typeAnnotation: TsType;
2520
+ }
2521
+ interface TsEnumDeclaration extends Node, HasSpan {
2522
+ type: "TsEnumDeclaration";
2523
+ declare: boolean;
2524
+ isConst: boolean;
2525
+ id: Identifier;
2526
+ members: TsEnumMember[];
2527
+ }
2528
+ interface TsEnumMember extends Node, HasSpan {
2529
+ type: "TsEnumMember";
2530
+ id: TsEnumMemberId;
2531
+ init?: Expression;
2532
+ }
2533
+ type TsEnumMemberId = Identifier | StringLiteral;
2534
+ interface TsModuleDeclaration extends Node, HasSpan {
2535
+ type: "TsModuleDeclaration";
2536
+ declare: boolean;
2537
+ global: boolean;
2538
+ id: TsModuleName;
2539
+ body?: TsNamespaceBody;
2540
+ }
2541
+ /**
2542
+ * `namespace A.B { }` is a namespace named `A` with another TsNamespaceDecl as its body.
2543
+ */
2544
+ type TsNamespaceBody = TsModuleBlock | TsNamespaceDeclaration;
2545
+ interface TsModuleBlock extends Node, HasSpan {
2546
+ type: "TsModuleBlock";
2547
+ body: ModuleItem[];
2548
+ }
2549
+ interface TsNamespaceDeclaration extends Node, HasSpan {
2550
+ type: "TsNamespaceDeclaration";
2551
+ declare: boolean;
2552
+ global: boolean;
2553
+ id: Identifier;
2554
+ body: TsNamespaceBody;
2555
+ }
2556
+ type TsModuleName = Identifier | StringLiteral;
2557
+ interface TsImportEqualsDeclaration extends Node, HasSpan {
2558
+ type: "TsImportEqualsDeclaration";
2559
+ declare: boolean;
2560
+ isExport: boolean;
2561
+ isTypeOnly: boolean;
2562
+ id: Identifier;
2563
+ moduleRef: TsModuleReference;
2564
+ }
2565
+ type TsModuleReference = TsEntityName | TsExternalModuleReference;
2566
+ interface TsExternalModuleReference extends Node, HasSpan {
2567
+ type: "TsExternalModuleReference";
2568
+ expression: StringLiteral;
2569
+ }
2570
+ interface TsExportAssignment extends Node, HasSpan {
2571
+ type: "TsExportAssignment";
2572
+ expression: Expression;
2573
+ }
2574
+ interface TsNamespaceExportDeclaration extends Node, HasSpan {
2575
+ type: "TsNamespaceExportDeclaration";
2576
+ id: Identifier;
2577
+ }
2578
+ interface TsAsExpression extends ExpressionBase {
2579
+ type: "TsAsExpression";
2580
+ expression: Expression;
2581
+ typeAnnotation: TsType;
2582
+ }
2583
+ interface TsSatisfiesExpression extends ExpressionBase {
2584
+ type: "TsSatisfiesExpression";
2585
+ expression: Expression;
2586
+ typeAnnotation: TsType;
2587
+ }
2588
+ interface TsInstantiation extends Node, HasSpan {
2589
+ type: "TsInstantiation";
2590
+ expression: Expression;
2591
+ typeArguments: TsTypeParameterInstantiation;
2592
+ }
2593
+ interface TsTypeAssertion extends ExpressionBase {
2594
+ type: "TsTypeAssertion";
2595
+ expression: Expression;
2596
+ typeAnnotation: TsType;
2597
+ }
2598
+ interface TsConstAssertion extends ExpressionBase {
2599
+ type: "TsConstAssertion";
2600
+ expression: Expression;
2601
+ }
2602
+ interface TsNonNullExpression extends ExpressionBase {
2603
+ type: "TsNonNullExpression";
2604
+ expression: Expression;
2605
+ }
2606
+ type Accessibility = "public" | "protected" | "private";
2607
+ interface Invalid extends Node, HasSpan {
2608
+ type: "Invalid";
2609
+ }
2610
+
731
2611
  interface Options$1 {
732
2612
  allowRegExp: boolean;
733
2613
  allowFunction: boolean;
@@ -899,14 +2779,16 @@ interface DirectoryMapping {
899
2779
  to: string;
900
2780
  }
901
2781
  interface Presets {
902
- apply(extension: 'typescript', config: TypescriptOptions, args?: Options$2): Promise<TypescriptOptions>;
2782
+ apply(extension: 'typescript', config: TypescriptOptions, args?: Options$3): Promise<TypescriptOptions>;
903
2783
  apply(extension: 'framework', config?: {}, args?: any): Promise<Preset>;
904
2784
  apply(extension: 'babel', config?: {}, args?: any): Promise<TransformOptions>;
2785
+ apply(extension: 'swc', config?: {}, args?: any): Promise<Options$2>;
905
2786
  apply(extension: 'entries', config?: [], args?: any): Promise<unknown>;
906
2787
  apply(extension: 'stories', config?: [], args?: any): Promise<StoriesEntry[]>;
907
2788
  apply(extension: 'managerEntries', config: [], args?: any): Promise<string[]>;
908
2789
  apply(extension: 'refs', config?: [], args?: any): Promise<unknown>;
909
2790
  apply(extension: 'core', config?: {}, args?: any): Promise<CoreConfig>;
2791
+ apply(extension: 'build', config?: {}, args?: any): Promise<StorybookConfig['build']>;
910
2792
  apply<T>(extension: string, config?: T, args?: unknown): Promise<T>;
911
2793
  }
912
2794
  interface LoadedPreset {
@@ -955,6 +2837,7 @@ interface CLIOptions {
955
2837
  quiet?: boolean;
956
2838
  versionUpdates?: boolean;
957
2839
  docs?: boolean;
2840
+ test?: boolean;
958
2841
  debugWebpack?: boolean;
959
2842
  webpackStatsJson?: string | boolean;
960
2843
  outputDir?: string;
@@ -974,7 +2857,9 @@ interface StorybookConfigOptions {
974
2857
  presets: Presets;
975
2858
  presetsList?: LoadedPreset[];
976
2859
  }
977
- type Options$2 = LoadOptions & StorybookConfigOptions & CLIOptions & BuilderOptions;
2860
+ type Options$3 = LoadOptions & StorybookConfigOptions & CLIOptions & BuilderOptions & {
2861
+ build?: TestBuildConfig;
2862
+ };
978
2863
  /**
979
2864
  * Options for TypeScript usage within Storybook.
980
2865
  */
@@ -1024,6 +2909,43 @@ type DocsOptions = {
1024
2909
  */
1025
2910
  docsMode?: boolean;
1026
2911
  };
2912
+ interface TestBuildFlags {
2913
+ /**
2914
+ * The package @storybook/blocks will be excluded from the bundle, even when imported in e.g. the preview.
2915
+ */
2916
+ emptyBlocks?: boolean;
2917
+ /**
2918
+ * Disable all addons
2919
+ */
2920
+ removeNonFastAddons?: boolean;
2921
+ /**
2922
+ * Filter out .mdx stories entries
2923
+ */
2924
+ removeMDXEntries?: boolean;
2925
+ /**
2926
+ * Override autodocs to be disabled
2927
+ */
2928
+ removeAutoDocs?: boolean;
2929
+ /**
2930
+ * Override docgen to be disabled.
2931
+ */
2932
+ disableDocgen?: boolean;
2933
+ /**
2934
+ * Override sourcemaps generation to be disabled.
2935
+ */
2936
+ disableSourcemaps?: boolean;
2937
+ /**
2938
+ * Override tree-shaking (dead code elimination) to be disabled.
2939
+ */
2940
+ disableTreeShaking?: boolean;
2941
+ /**
2942
+ * Compile/Optimize with SWC.
2943
+ */
2944
+ optimizeCompilation?: boolean;
2945
+ }
2946
+ interface TestBuildConfig {
2947
+ test?: TestBuildFlags;
2948
+ }
1027
2949
  /**
1028
2950
  * The interface for Storybook configuration in `main.ts` files.
1029
2951
  */
@@ -1074,6 +2996,7 @@ interface StorybookConfig {
1074
2996
  */
1075
2997
  legacyDecoratorFileOrder?: boolean;
1076
2998
  };
2999
+ build?: TestBuildConfig;
1077
3000
  /**
1078
3001
  * Tells Storybook where to find stories.
1079
3002
  *
@@ -1095,7 +3018,11 @@ interface StorybookConfig {
1095
3018
  /**
1096
3019
  * Modify or return babel config.
1097
3020
  */
1098
- babel?: (config: TransformOptions, options: Options$2) => TransformOptions | Promise<TransformOptions>;
3021
+ babel?: (config: TransformOptions, options: Options$3) => TransformOptions | Promise<TransformOptions>;
3022
+ /**
3023
+ * Modify or return swc config.
3024
+ */
3025
+ swc?: (config: Options$2, options: Options$3) => Options$2 | Promise<Options$2>;
1099
3026
  /**
1100
3027
  * Modify or return env config.
1101
3028
  */
@@ -1103,7 +3030,7 @@ interface StorybookConfig {
1103
3030
  /**
1104
3031
  * Modify or return babel config.
1105
3032
  */
1106
- babelDefault?: (config: TransformOptions, options: Options$2) => TransformOptions | Promise<TransformOptions>;
3033
+ babelDefault?: (config: TransformOptions, options: Options$3) => TransformOptions | Promise<TransformOptions>;
1107
3034
  /**
1108
3035
  * Add additional scripts to run in the preview a la `.storybook/preview.js`
1109
3036
  *
@@ -1149,7 +3076,7 @@ interface StorybookConfig {
1149
3076
  */
1150
3077
  managerHead?: PresetValue<string>;
1151
3078
  }
1152
- type PresetValue<T> = T | ((config: T, options: Options$2) => T | Promise<T>);
3079
+ type PresetValue<T> = T | ((config: T, options: Options$3) => T | Promise<T>);
1153
3080
  type Path = string;
1154
3081
 
1155
3082
  declare const monorepoConfigs: {