@storybook/server-webpack5 7.6.0-alpha.4 → 7.6.0-alpha.5

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