webpack 5.90.3 → 5.92.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of webpack might be problematic. Click here for more details.

Files changed (257) hide show
  1. package/README.md +5 -5
  2. package/bin/webpack.js +6 -3
  3. package/lib/APIPlugin.js +14 -6
  4. package/lib/AutomaticPrefetchPlugin.js +1 -1
  5. package/lib/BannerPlugin.js +3 -1
  6. package/lib/Cache.js +8 -2
  7. package/lib/CacheFacade.js +3 -3
  8. package/lib/Chunk.js +7 -4
  9. package/lib/ChunkGraph.js +52 -25
  10. package/lib/ChunkGroup.js +23 -17
  11. package/lib/CleanPlugin.js +8 -6
  12. package/lib/Compilation.js +295 -120
  13. package/lib/Compiler.js +223 -87
  14. package/lib/ConcatenationScope.js +3 -3
  15. package/lib/ConditionalInitFragment.js +4 -5
  16. package/lib/ContextModule.js +95 -41
  17. package/lib/ContextModuleFactory.js +4 -2
  18. package/lib/ContextReplacementPlugin.js +3 -2
  19. package/lib/DefinePlugin.js +18 -6
  20. package/lib/Dependency.js +12 -10
  21. package/lib/DependencyTemplate.js +17 -7
  22. package/lib/DllModule.js +1 -0
  23. package/lib/DllReferencePlugin.js +7 -3
  24. package/lib/EntryOptionPlugin.js +4 -1
  25. package/lib/EntryPlugin.js +6 -1
  26. package/lib/Entrypoint.js +1 -1
  27. package/lib/EvalDevToolModulePlugin.js +11 -0
  28. package/lib/ExportsInfo.js +23 -8
  29. package/lib/ExternalModule.js +160 -35
  30. package/lib/ExternalModuleFactoryPlugin.js +37 -2
  31. package/lib/FileSystemInfo.js +69 -42
  32. package/lib/FlagDependencyExportsPlugin.js +21 -7
  33. package/lib/Generator.js +4 -4
  34. package/lib/HookWebpackError.js +2 -2
  35. package/lib/HotModuleReplacementPlugin.js +108 -45
  36. package/lib/IgnorePlugin.js +4 -1
  37. package/lib/InitFragment.js +5 -3
  38. package/lib/LibManifestPlugin.js +17 -9
  39. package/lib/Module.js +41 -14
  40. package/lib/ModuleFactory.js +3 -3
  41. package/lib/ModuleFilenameHelpers.js +30 -17
  42. package/lib/ModuleGraph.js +60 -31
  43. package/lib/ModuleGraphConnection.js +2 -1
  44. package/lib/MultiCompiler.js +62 -9
  45. package/lib/NodeStuffPlugin.js +14 -3
  46. package/lib/NormalModule.js +13 -13
  47. package/lib/NormalModuleFactory.js +18 -9
  48. package/lib/NormalModuleReplacementPlugin.js +5 -1
  49. package/lib/Parser.js +1 -1
  50. package/lib/PlatformPlugin.js +39 -0
  51. package/lib/ProgressPlugin.js +1 -1
  52. package/lib/ProvidePlugin.js +3 -1
  53. package/lib/RawModule.js +2 -1
  54. package/lib/RecordIdsPlugin.js +4 -4
  55. package/lib/ResolverFactory.js +6 -4
  56. package/lib/RuntimeModule.js +4 -4
  57. package/lib/RuntimePlugin.js +1 -0
  58. package/lib/RuntimeTemplate.js +124 -52
  59. package/lib/SourceMapDevToolPlugin.js +4 -1
  60. package/lib/Stats.js +11 -4
  61. package/lib/Template.js +5 -5
  62. package/lib/TemplatedPathPlugin.js +48 -7
  63. package/lib/Watching.js +67 -60
  64. package/lib/WebpackError.js +6 -6
  65. package/lib/WebpackOptionsApply.js +18 -5
  66. package/lib/asset/AssetGenerator.js +15 -0
  67. package/lib/asset/RawDataUrlModule.js +3 -1
  68. package/lib/async-modules/AwaitDependenciesInitFragment.js +2 -2
  69. package/lib/buildChunkGraph.js +120 -67
  70. package/lib/cache/IdleFileCachePlugin.js +8 -3
  71. package/lib/cache/MemoryCachePlugin.js +1 -1
  72. package/lib/cache/MemoryWithGcCachePlugin.js +6 -2
  73. package/lib/cache/PackFileCacheStrategy.js +51 -18
  74. package/lib/cache/ResolverCachePlugin.js +22 -14
  75. package/lib/cache/getLazyHashedEtag.js +2 -2
  76. package/lib/cli.js +5 -5
  77. package/lib/config/browserslistTargetHandler.js +7 -1
  78. package/lib/config/defaults.js +108 -34
  79. package/lib/config/normalization.js +3 -1
  80. package/lib/config/target.js +18 -11
  81. package/lib/container/ContainerEntryDependency.js +2 -1
  82. package/lib/container/ContainerEntryModule.js +4 -2
  83. package/lib/container/ContainerPlugin.js +14 -10
  84. package/lib/container/FallbackModule.js +1 -1
  85. package/lib/container/RemoteRuntimeModule.js +12 -3
  86. package/lib/css/CssExportsGenerator.js +68 -25
  87. package/lib/css/CssGenerator.js +34 -6
  88. package/lib/css/CssLoadingRuntimeModule.js +217 -98
  89. package/lib/css/CssModulesPlugin.js +238 -107
  90. package/lib/css/CssParser.js +24 -15
  91. package/lib/css/walkCssTokens.js +1 -1
  92. package/lib/debug/ProfilingPlugin.js +28 -3
  93. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +9 -5
  94. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +4 -1
  95. package/lib/dependencies/CommonJsDependencyHelpers.js +2 -1
  96. package/lib/dependencies/CommonJsExportRequireDependency.js +33 -18
  97. package/lib/dependencies/CommonJsExportsDependency.js +13 -5
  98. package/lib/dependencies/CommonJsExportsParserPlugin.js +20 -15
  99. package/lib/dependencies/CommonJsImportsParserPlugin.js +1 -2
  100. package/lib/dependencies/ContextDependencyHelpers.js +49 -29
  101. package/lib/dependencies/ContextElementDependency.js +8 -1
  102. package/lib/dependencies/CssExportDependency.js +2 -2
  103. package/lib/dependencies/CssLocalIdentifierDependency.js +71 -9
  104. package/lib/dependencies/CssUrlDependency.js +10 -7
  105. package/lib/dependencies/ExportsInfoDependency.js +5 -4
  106. package/lib/dependencies/ExternalModuleDependency.js +4 -2
  107. package/lib/dependencies/ExternalModuleInitFragment.js +5 -3
  108. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +4 -4
  109. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +43 -23
  110. package/lib/dependencies/HarmonyExportHeaderDependency.js +1 -1
  111. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +73 -32
  112. package/lib/dependencies/HarmonyExportInitFragment.js +10 -2
  113. package/lib/dependencies/HarmonyImportDependency.js +28 -12
  114. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +70 -19
  115. package/lib/dependencies/HarmonyImportSideEffectDependency.js +7 -6
  116. package/lib/dependencies/HarmonyImportSpecifierDependency.js +47 -35
  117. package/lib/dependencies/ImportDependency.js +9 -2
  118. package/lib/dependencies/ImportEagerDependency.js +4 -2
  119. package/lib/dependencies/ImportMetaContextDependency.js +7 -0
  120. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +25 -14
  121. package/lib/dependencies/ImportMetaPlugin.js +1 -1
  122. package/lib/dependencies/ImportParserPlugin.js +15 -5
  123. package/lib/dependencies/ImportWeakDependency.js +4 -2
  124. package/lib/dependencies/LoaderDependency.js +2 -1
  125. package/lib/dependencies/LoaderImportDependency.js +2 -1
  126. package/lib/dependencies/LoaderPlugin.js +2 -2
  127. package/lib/dependencies/ModuleDependency.js +4 -5
  128. package/lib/dependencies/PureExpressionDependency.js +64 -47
  129. package/lib/dependencies/RequireContextPlugin.js +1 -1
  130. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +26 -14
  131. package/lib/dependencies/RequireEnsureDependency.js +1 -1
  132. package/lib/dependencies/URLDependency.js +7 -4
  133. package/lib/dependencies/WorkerDependency.js +1 -1
  134. package/lib/dependencies/WorkerPlugin.js +2 -1
  135. package/lib/dependencies/getFunctionExpression.js +3 -1
  136. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +92 -3
  137. package/lib/hmr/LazyCompilationPlugin.js +2 -2
  138. package/lib/ids/ChunkModuleIdRangePlugin.js +1 -1
  139. package/lib/ids/DeterministicChunkIdsPlugin.js +1 -1
  140. package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
  141. package/lib/ids/IdHelpers.js +6 -6
  142. package/lib/ids/NamedChunkIdsPlugin.js +1 -1
  143. package/lib/ids/NamedModuleIdsPlugin.js +1 -1
  144. package/lib/ids/SyncModuleIdsPlugin.js +2 -2
  145. package/lib/index.js +11 -0
  146. package/lib/javascript/BasicEvaluatedExpression.js +2 -2
  147. package/lib/javascript/ChunkHelpers.js +2 -2
  148. package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -1
  149. package/lib/javascript/JavascriptGenerator.js +0 -1
  150. package/lib/javascript/JavascriptModulesPlugin.js +174 -17
  151. package/lib/javascript/JavascriptParser.js +204 -71
  152. package/lib/javascript/JavascriptParserHelpers.js +1 -1
  153. package/lib/javascript/StartupHelpers.js +22 -5
  154. package/lib/library/AbstractLibraryPlugin.js +2 -2
  155. package/lib/library/AmdLibraryPlugin.js +2 -2
  156. package/lib/library/AssignLibraryPlugin.js +3 -3
  157. package/lib/library/ExportPropertyLibraryPlugin.js +2 -2
  158. package/lib/library/JsonpLibraryPlugin.js +2 -2
  159. package/lib/library/ModuleLibraryPlugin.js +2 -2
  160. package/lib/library/SystemLibraryPlugin.js +2 -2
  161. package/lib/library/UmdLibraryPlugin.js +33 -12
  162. package/lib/logging/Logger.js +27 -2
  163. package/lib/logging/createConsoleLogger.js +13 -9
  164. package/lib/node/CommonJsChunkLoadingPlugin.js +2 -1
  165. package/lib/node/NodeEnvironmentPlugin.js +14 -8
  166. package/lib/node/NodeTemplatePlugin.js +1 -1
  167. package/lib/node/NodeWatchFileSystem.js +37 -26
  168. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -1
  169. package/lib/node/ReadFileCompileWasmPlugin.js +1 -1
  170. package/lib/node/RequireChunkLoadingRuntimeModule.js +2 -1
  171. package/lib/node/nodeConsole.js +24 -1
  172. package/lib/optimize/AggressiveMergingPlugin.js +1 -1
  173. package/lib/optimize/AggressiveSplittingPlugin.js +1 -0
  174. package/lib/optimize/ConcatenatedModule.js +140 -121
  175. package/lib/optimize/EnsureChunkConditionsPlugin.js +1 -1
  176. package/lib/optimize/InnerGraph.js +8 -3
  177. package/lib/optimize/InnerGraphPlugin.js +36 -13
  178. package/lib/optimize/LimitChunkCountPlugin.js +1 -2
  179. package/lib/optimize/ModuleConcatenationPlugin.js +13 -3
  180. package/lib/optimize/RealContentHashPlugin.js +3 -3
  181. package/lib/optimize/RemoveParentModulesPlugin.js +1 -0
  182. package/lib/optimize/RuntimeChunkPlugin.js +6 -1
  183. package/lib/optimize/SideEffectsFlagPlugin.js +48 -17
  184. package/lib/optimize/SplitChunksPlugin.js +10 -10
  185. package/lib/performance/SizeLimitsPlugin.js +13 -2
  186. package/lib/rules/ObjectMatcherRulePlugin.js +15 -1
  187. package/lib/rules/RuleSetCompiler.js +9 -7
  188. package/lib/runtime/EnsureChunkRuntimeModule.js +2 -1
  189. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +2 -1
  190. package/lib/runtime/LoadScriptRuntimeModule.js +1 -1
  191. package/lib/runtime/StartupChunkDependenciesPlugin.js +1 -1
  192. package/lib/schemes/HttpUriPlugin.js +1 -1
  193. package/lib/serialization/BinaryMiddleware.js +4 -4
  194. package/lib/serialization/FileMiddleware.js +4 -3
  195. package/lib/serialization/NullPrototypeObjectSerializer.js +2 -2
  196. package/lib/serialization/ObjectMiddleware.js +8 -5
  197. package/lib/serialization/PlainObjectSerializer.js +2 -2
  198. package/lib/serialization/Serializer.js +19 -0
  199. package/lib/serialization/SerializerMiddleware.js +2 -2
  200. package/lib/serialization/SingleItemMiddleware.js +2 -2
  201. package/lib/serialization/types.js +1 -1
  202. package/lib/sharing/ConsumeSharedModule.js +2 -2
  203. package/lib/sharing/ConsumeSharedPlugin.js +17 -3
  204. package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -2
  205. package/lib/sharing/ProvideSharedPlugin.js +13 -6
  206. package/lib/sharing/resolveMatchedConfigs.js +3 -3
  207. package/lib/sharing/utils.js +13 -6
  208. package/lib/stats/DefaultStatsFactoryPlugin.js +20 -20
  209. package/lib/stats/DefaultStatsPrinterPlugin.js +1 -1
  210. package/lib/stats/StatsFactory.js +2 -2
  211. package/lib/stats/StatsPrinter.js +6 -6
  212. package/lib/util/ArrayQueue.js +14 -21
  213. package/lib/util/AsyncQueue.js +1 -1
  214. package/lib/util/Queue.js +8 -2
  215. package/lib/util/SortableSet.js +16 -4
  216. package/lib/util/StackedCacheMap.js +26 -0
  217. package/lib/util/TupleQueue.js +8 -2
  218. package/lib/util/WeakTupleMap.js +57 -13
  219. package/lib/util/binarySearchBounds.js +1 -1
  220. package/lib/util/cleverMerge.js +26 -13
  221. package/lib/util/comparators.js +37 -15
  222. package/lib/util/conventions.js +129 -0
  223. package/lib/util/createHash.js +3 -5
  224. package/lib/util/deprecation.js +3 -3
  225. package/lib/util/deterministicGrouping.js +2 -2
  226. package/lib/util/findGraphRoots.js +1 -1
  227. package/lib/util/fs.js +383 -69
  228. package/lib/util/hash/BatchedHash.js +3 -0
  229. package/lib/util/hash/xxhash64.js +2 -2
  230. package/lib/util/identifier.js +5 -5
  231. package/lib/util/mergeScope.js +79 -0
  232. package/lib/util/runtime.js +2 -17
  233. package/lib/util/semver.js +3 -0
  234. package/lib/util/smartGrouping.js +3 -3
  235. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +4 -2
  236. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -1
  237. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +4 -2
  238. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -3
  239. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +16 -7
  240. package/lib/wasm-sync/WebAssemblyGenerator.js +40 -19
  241. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +1 -1
  242. package/lib/wasm-sync/WebAssemblyParser.js +7 -4
  243. package/lib/wasm-sync/WebAssemblyUtils.js +2 -1
  244. package/lib/web/FetchCompileWasmPlugin.js +1 -1
  245. package/lib/web/JsonpChunkLoadingRuntimeModule.js +3 -2
  246. package/lib/webpack.js +19 -6
  247. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +2 -1
  248. package/package.json +40 -39
  249. package/schemas/WebpackOptions.check.js +1 -1
  250. package/schemas/WebpackOptions.json +97 -8
  251. package/schemas/plugins/BannerPlugin.check.js +1 -1
  252. package/schemas/plugins/BannerPlugin.json +5 -1
  253. package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +1 -1
  254. package/schemas/plugins/css/CssGeneratorOptions.check.js +1 -1
  255. package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +1 -1
  256. package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
  257. package/types.d.ts +1826 -639
@@ -6,7 +6,7 @@
6
6
  "use strict";
7
7
 
8
8
  const { Parser: AcornParser } = require("acorn");
9
- const { importAssertions } = require("acorn-import-assertions");
9
+ const { importAttributesOrAssertions } = require("acorn-import-attributes");
10
10
  const { SyncBailHook, HookMap } = require("tapable");
11
11
  const vm = require("vm");
12
12
  const Parser = require("../Parser");
@@ -87,13 +87,19 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
87
87
  /** @typedef {import("estree").Super} Super */
88
88
  /** @typedef {import("estree").TaggedTemplateExpression} TaggedTemplateExpression */
89
89
  /** @typedef {import("estree").TemplateLiteral} TemplateLiteral */
90
- /** @typedef {Record<string, any>} Assertions */
91
- /** @template T @typedef {import("tapable").AsArray<T>} AsArray<T> */
90
+ /** @typedef {import("estree").AssignmentProperty} AssignmentProperty */
91
+ /**
92
+ * @template T
93
+ * @typedef {import("tapable").AsArray<T>} AsArray<T>
94
+ */
92
95
  /** @typedef {import("../Parser").ParserState} ParserState */
93
96
  /** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
94
97
  /** @typedef {{declaredScope: ScopeInfo, freeName: string | true, tagInfo: TagInfo | undefined}} VariableInfoInterface */
95
98
  /** @typedef {{ name: string | VariableInfo, rootInfo: string | VariableInfo, getMembers: () => string[], getMembersOptionals: () => boolean[], getMemberRanges: () => Range[] }} GetInfoResult */
96
99
  /** @typedef {Statement | ModuleDeclaration | Expression} StatementPathItem */
100
+ /** @typedef {TODO} OnIdent */
101
+
102
+ /** @typedef {Record<string, string> & { _isLegacyAssert?: boolean }} ImportAttributes */
97
103
 
98
104
  /** @type {string[]} */
99
105
  const EMPTY_ARRAY = [];
@@ -103,7 +109,7 @@ const ALLOWED_MEMBER_TYPES_ALL = 0b11;
103
109
 
104
110
  // Syntax: https://developer.mozilla.org/en/SpiderMonkey/Parser_API
105
111
 
106
- const parser = AcornParser.extend(importAssertions);
112
+ const parser = AcornParser.extend(importAttributesOrAssertions);
107
113
 
108
114
  class VariableInfo {
109
115
  /**
@@ -123,14 +129,14 @@ class VariableInfo {
123
129
  /** @typedef {Omit<AcornOptions, "sourceType" | "ecmaVersion"> & { sourceType: "module" | "script" | "auto", ecmaVersion?: AcornOptions["ecmaVersion"] }} ParseOptions */
124
130
 
125
131
  /**
126
- * @typedef {Object} TagInfo
132
+ * @typedef {object} TagInfo
127
133
  * @property {any} tag
128
134
  * @property {any} data
129
135
  * @property {TagInfo | undefined} next
130
136
  */
131
137
 
132
138
  /**
133
- * @typedef {Object} ScopeInfo
139
+ * @typedef {object} ScopeInfo
134
140
  * @property {StackedMap<string, VariableInfo | ScopeInfo>} definitions
135
141
  * @property {boolean | "arrow"} topLevelScope
136
142
  * @property {boolean | string} inShorthand
@@ -142,6 +148,13 @@ class VariableInfo {
142
148
 
143
149
  /** @typedef {[number, number]} Range */
144
150
 
151
+ /**
152
+ * @typedef {object} DestructuringAssignmentProperty
153
+ * @property {string} id
154
+ * @property {Range | undefined=} range
155
+ * @property {boolean | string} shorthand
156
+ */
157
+
145
158
  /**
146
159
  * Helper function for joining two ranges into a single range. This is useful
147
160
  * when working with AST nodes, as it allows you to combine the ranges of child nodes
@@ -257,7 +270,7 @@ class JavascriptParser extends Parser {
257
270
  evaluateCallExpression: new HookMap(
258
271
  () => new SyncBailHook(["expression"])
259
272
  ),
260
- /** @type {HookMap<SyncBailHook<[CallExpression, BasicEvaluatedExpression | undefined], BasicEvaluatedExpression | undefined | null>>} */
273
+ /** @type {HookMap<SyncBailHook<[CallExpression, BasicEvaluatedExpression], BasicEvaluatedExpression | undefined | null>>} */
261
274
  evaluateCallExpressionMember: new HookMap(
262
275
  () => new SyncBailHook(["expression", "param"])
263
276
  ),
@@ -298,15 +311,15 @@ class JavascriptParser extends Parser {
298
311
  "exportName",
299
312
  "identifierName"
300
313
  ]),
301
- /** @type {SyncBailHook<[ExportNamedDeclaration | ExportAllDeclaration], boolean | void>} */
314
+ /** @type {SyncBailHook<[ExportDefaultDeclaration | ExportNamedDeclaration], boolean | void>} */
302
315
  export: new SyncBailHook(["statement"]),
303
316
  /** @type {SyncBailHook<[ExportNamedDeclaration | ExportAllDeclaration, ImportSource], boolean | void>} */
304
317
  exportImport: new SyncBailHook(["statement", "source"]),
305
- /** @type {SyncBailHook<[ExportNamedDeclaration | ExportAllDeclaration, Declaration], boolean | void>} */
318
+ /** @type {SyncBailHook<[ExportDefaultDeclaration | ExportNamedDeclaration | ExportAllDeclaration, Declaration], boolean | void>} */
306
319
  exportDeclaration: new SyncBailHook(["statement", "declaration"]),
307
- /** @type {SyncBailHook<[ExportDefaultDeclaration, Declaration], boolean | void>} */
320
+ /** @type {SyncBailHook<[ExportDefaultDeclaration, FunctionDeclaration | ClassDeclaration], boolean | void>} */
308
321
  exportExpression: new SyncBailHook(["statement", "declaration"]),
309
- /** @type {SyncBailHook<[ExportNamedDeclaration | ExportAllDeclaration, string, string, number | undefined], boolean | void>} */
322
+ /** @type {SyncBailHook<[ExportDefaultDeclaration | ExportNamedDeclaration | ExportAllDeclaration, string, string, number | undefined], boolean | void>} */
310
323
  exportSpecifier: new SyncBailHook([
311
324
  "statement",
312
325
  "identifierName",
@@ -349,7 +362,7 @@ class JavascriptParser extends Parser {
349
362
  typeof: new HookMap(() => new SyncBailHook(["expression"])),
350
363
  /** @type {SyncBailHook<[ImportExpression], boolean | void>} */
351
364
  importCall: new SyncBailHook(["expression"]),
352
- /** @type {SyncBailHook<[Expression], boolean | void>} */
365
+ /** @type {SyncBailHook<[Expression | ForOfStatement], boolean | void>} */
353
366
  topLevelAwait: new SyncBailHook(["expression"]),
354
367
  /** @type {HookMap<SyncBailHook<[CallExpression], boolean | void>>} */
355
368
  call: new HookMap(() => new SyncBailHook(["expression"])),
@@ -432,7 +445,7 @@ class JavascriptParser extends Parser {
432
445
  this.statementPath = undefined;
433
446
  /** @type {Statement | ModuleDeclaration | Expression | undefined} */
434
447
  this.prevStatement = undefined;
435
- /** @type {WeakMap<Expression, Set<string>> | undefined} */
448
+ /** @type {WeakMap<Expression, Set<DestructuringAssignmentProperty>> | undefined} */
436
449
  this.destructuringAssignmentProperties = undefined;
437
450
  this.currentTagData = undefined;
438
451
  this.magicCommentContext = vm.createContext(undefined, {
@@ -600,7 +613,7 @@ class JavascriptParser extends Parser {
600
613
  *
601
614
  * import("./" + foo + bar); // webpack will auto evaluate this into import("./foobar")
602
615
  * ```
603
- * @param {boolean | number | BigInt | string} value the value to convert to an expression
616
+ * @param {boolean | number | bigint | string} value the value to convert to an expression
604
617
  * @param {BinaryExpression | UnaryExpression} expr the expression being evaluated
605
618
  * @param {boolean} sideEffects whether the expression has side effects
606
619
  * @returns {BasicEvaluatedExpression | undefined} the evaluated expression
@@ -658,7 +671,7 @@ class JavascriptParser extends Parser {
658
671
  * Evaluates a binary expression if and only if it is a const operation (e.g. 1 + 2, "a" + "b", etc.).
659
672
  *
660
673
  * @template T
661
- * @param {(leftOperand: T, rightOperand: T) => boolean | number | BigInt | string} operandHandler the handler for the operation (e.g. (a, b) => a + b)
674
+ * @param {(leftOperand: T, rightOperand: T) => boolean | number | bigint | string} operandHandler the handler for the operation (e.g. (a, b) => a + b)
662
675
  * @returns {BasicEvaluatedExpression | undefined} the evaluated expression
663
676
  */
664
677
  const handleConstOperation = operandHandler => {
@@ -880,7 +893,12 @@ class JavascriptParser extends Parser {
880
893
  /** @type {string} */ (left.string) +
881
894
  /** @type {string} */ (right.prefix.string)
882
895
  )
883
- .setRange(joinRanges(left.range, right.prefix.range)),
896
+ .setRange(
897
+ joinRanges(
898
+ /** @type {Range} */ (left.range),
899
+ /** @type {Range} */ (right.prefix.range)
900
+ )
901
+ ),
884
902
  right.postfix,
885
903
  right.wrappedInnerExpressions
886
904
  );
@@ -901,7 +919,10 @@ class JavascriptParser extends Parser {
901
919
  if (right.isString()) {
902
920
  res.setString(left.number + /** @type {string} */ (right.string));
903
921
  } else if (right.isNumber()) {
904
- res.setNumber(left.number + right.number);
922
+ res.setNumber(
923
+ /** @type {number} */ (left.number) +
924
+ /** @type {number} */ (right.number)
925
+ );
905
926
  } else {
906
927
  return;
907
928
  }
@@ -1063,7 +1084,7 @@ class JavascriptParser extends Parser {
1063
1084
  * Evaluates a UnaryExpression if and only if it is a basic const operator (e.g. +a, -a, ~a).
1064
1085
  *
1065
1086
  * @template T
1066
- * @param {(operand: T) => boolean | number | BigInt | string} operandHandler handler for the operand
1087
+ * @param {(operand: T) => boolean | number | bigint | string} operandHandler handler for the operand
1067
1088
  * @returns {BasicEvaluatedExpression | undefined} evaluated expression
1068
1089
  */
1069
1090
  const handleConstOperation = operandHandler => {
@@ -1328,7 +1349,7 @@ class JavascriptParser extends Parser {
1328
1349
  if (arg1.type === "SpreadElement") return;
1329
1350
  const arg1Eval = this.evaluateExpression(arg1);
1330
1351
  if (!arg1Eval.isString()) return;
1331
- const arg1Value = arg1Eval.string;
1352
+ const arg1Value = /** @type {string} */ (arg1Eval.string);
1332
1353
 
1333
1354
  let result;
1334
1355
  if (arg2) {
@@ -1357,9 +1378,11 @@ class JavascriptParser extends Parser {
1357
1378
  let arg1 = this.evaluateExpression(expr.arguments[0]);
1358
1379
  let arg2 = this.evaluateExpression(expr.arguments[1]);
1359
1380
  if (!arg1.isString() && !arg1.isRegExp()) return;
1360
- const arg1Value = arg1.regExp || arg1.string;
1381
+ const arg1Value = /** @type {string | RegExp} */ (
1382
+ arg1.regExp || arg1.string
1383
+ );
1361
1384
  if (!arg2.isString()) return;
1362
- const arg2Value = arg2.string;
1385
+ const arg2Value = /** @type {string} */ (arg2.string);
1363
1386
  return new BasicEvaluatedExpression()
1364
1387
  .setString(
1365
1388
  /** @type {string} */ (param.string).replace(arg1Value, arg2Value)
@@ -1380,7 +1403,9 @@ class JavascriptParser extends Parser {
1380
1403
  if (expr.arguments[0].type === "SpreadElement") return;
1381
1404
  arg1 = this.evaluateExpression(expr.arguments[0]);
1382
1405
  if (!arg1.isNumber()) return;
1383
- result = str[fn](arg1.number);
1406
+ result = str[
1407
+ /** @type {"substr" | "substring" | "slice"} */ (fn)
1408
+ ](/** @type {number} */ (arg1.number));
1384
1409
  break;
1385
1410
  case 2: {
1386
1411
  if (expr.arguments[0].type === "SpreadElement") return;
@@ -1389,7 +1414,12 @@ class JavascriptParser extends Parser {
1389
1414
  const arg2 = this.evaluateExpression(expr.arguments[1]);
1390
1415
  if (!arg1.isNumber()) return;
1391
1416
  if (!arg2.isNumber()) return;
1392
- result = str[fn](arg1.number, arg2.number);
1417
+ result = str[
1418
+ /** @type {"substr" | "substring" | "slice"} */ (fn)
1419
+ ](
1420
+ /** @type {number} */ (arg1.number),
1421
+ /** @type {number} */ (arg2.number)
1422
+ );
1393
1423
  break;
1394
1424
  }
1395
1425
  default:
@@ -1443,7 +1473,7 @@ class JavascriptParser extends Parser {
1443
1473
  }
1444
1474
 
1445
1475
  const part = new BasicEvaluatedExpression()
1446
- .setString(quasi)
1476
+ .setString(/** @type {string} */ (quasi))
1447
1477
  .setRange(/** @type {Range} */ (quasiExpr.range))
1448
1478
  .setExpression(quasiExpr);
1449
1479
  quasis.push(part);
@@ -1489,7 +1519,6 @@ class JavascriptParser extends Parser {
1489
1519
  .for("concat")
1490
1520
  .tap("JavascriptParser", (expr, param) => {
1491
1521
  if (!param.isString() && !param.isWrapped()) return;
1492
-
1493
1522
  let stringSuffix = null;
1494
1523
  let hasUnknownParams = false;
1495
1524
  const innerExpressions = [];
@@ -1569,7 +1598,9 @@ class JavascriptParser extends Parser {
1569
1598
  /** @type {string} */
1570
1599
  (param.string).split(/** @type {string} */ (arg.string));
1571
1600
  } else if (arg.isRegExp()) {
1572
- result = /** @type {string} */ (param.string).split(arg.regExp);
1601
+ result = /** @type {string} */ (param.string).split(
1602
+ /** @type {RegExp} */ (arg.regExp)
1603
+ );
1573
1604
  } else {
1574
1605
  return;
1575
1606
  }
@@ -1627,7 +1658,7 @@ class JavascriptParser extends Parser {
1627
1658
  });
1628
1659
  if (!items.every(Boolean)) return;
1629
1660
  return new BasicEvaluatedExpression()
1630
- .setItems(items)
1661
+ .setItems(/** @type {BasicEvaluatedExpression[]} */ (items))
1631
1662
  .setRange(/** @type {Range} */ (expr.range));
1632
1663
  });
1633
1664
  this.hooks.evaluate
@@ -1678,7 +1709,7 @@ class JavascriptParser extends Parser {
1678
1709
 
1679
1710
  /**
1680
1711
  * @param {Expression} node node
1681
- * @returns {Set<string>|undefined} destructured identifiers
1712
+ * @returns {Set<DestructuringAssignmentProperty> | undefined} destructured identifiers
1682
1713
  */
1683
1714
  destructuringAssignmentPropertiesFor(node) {
1684
1715
  if (!this.destructuringAssignmentProperties) return undefined;
@@ -2213,6 +2244,9 @@ class JavascriptParser extends Parser {
2213
2244
  });
2214
2245
  }
2215
2246
 
2247
+ /**
2248
+ * @param {ForOfStatement} statement statement
2249
+ */
2216
2250
  preWalkForOfStatement(statement) {
2217
2251
  if (statement.await && this.scope.topLevelScope === true) {
2218
2252
  this.hooks.topLevelAwait.call(statement);
@@ -2305,7 +2339,9 @@ class JavascriptParser extends Parser {
2305
2339
 
2306
2340
  // check multiple assignments
2307
2341
  if (this.destructuringAssignmentProperties.has(expression)) {
2308
- const set = this.destructuringAssignmentProperties.get(expression);
2342
+ const set =
2343
+ /** @type {Set<DestructuringAssignmentProperty>} */
2344
+ (this.destructuringAssignmentProperties.get(expression));
2309
2345
  this.destructuringAssignmentProperties.delete(expression);
2310
2346
  for (const id of set) keys.add(id);
2311
2347
  }
@@ -2322,8 +2358,11 @@ class JavascriptParser extends Parser {
2322
2358
  }
2323
2359
  }
2324
2360
 
2361
+ /**
2362
+ * @param {ImportDeclaration} statement statement
2363
+ */
2325
2364
  blockPreWalkImportDeclaration(statement) {
2326
- const source = statement.source.value;
2365
+ const source = /** @type {ImportSource} */ (statement.source.value);
2327
2366
  this.hooks.import.call(statement, source);
2328
2367
  for (const specifier of statement.specifiers) {
2329
2368
  const name = specifier.local.name;
@@ -2340,7 +2379,12 @@ class JavascriptParser extends Parser {
2340
2379
  !this.hooks.importSpecifier.call(
2341
2380
  statement,
2342
2381
  source,
2343
- specifier.imported.name || specifier.imported.value,
2382
+ specifier.imported.name ||
2383
+ // eslint-disable-next-line no-warning-comments
2384
+ // @ts-ignore
2385
+ // Old version of acorn used it
2386
+ // TODO drop it in webpack@6
2387
+ specifier.imported.value,
2344
2388
  name
2345
2389
  )
2346
2390
  ) {
@@ -2360,7 +2404,7 @@ class JavascriptParser extends Parser {
2360
2404
 
2361
2405
  /**
2362
2406
  * @param {Declaration} declaration declaration
2363
- * @param {TODO} onIdent on ident callback
2407
+ * @param {OnIdent} onIdent on ident callback
2364
2408
  */
2365
2409
  enterDeclaration(declaration, onIdent) {
2366
2410
  switch (declaration.type) {
@@ -2383,10 +2427,13 @@ class JavascriptParser extends Parser {
2383
2427
  }
2384
2428
  }
2385
2429
 
2430
+ /**
2431
+ * @param {ExportNamedDeclaration} statement statement
2432
+ */
2386
2433
  blockPreWalkExportNamedDeclaration(statement) {
2387
2434
  let source;
2388
2435
  if (statement.source) {
2389
- source = statement.source.value;
2436
+ source = /** @type {ImportSource} */ (statement.source.value);
2390
2437
  this.hooks.exportImport.call(statement, source);
2391
2438
  } else {
2392
2439
  this.hooks.export.call(statement);
@@ -2414,7 +2461,13 @@ class JavascriptParser extends Parser {
2414
2461
  const specifier = statement.specifiers[specifierIndex];
2415
2462
  switch (specifier.type) {
2416
2463
  case "ExportSpecifier": {
2417
- const name = specifier.exported.name || specifier.exported.value;
2464
+ const name =
2465
+ specifier.exported.name ||
2466
+ // eslint-disable-next-line no-warning-comments
2467
+ // @ts-ignore
2468
+ // Old version of acorn used it
2469
+ // TODO drop it in webpack@6
2470
+ specifier.exported.value;
2418
2471
  if (source) {
2419
2472
  this.hooks.exportImportSpecifier.call(
2420
2473
  statement,
@@ -2447,36 +2500,50 @@ class JavascriptParser extends Parser {
2447
2500
  }
2448
2501
  }
2449
2502
 
2503
+ /**
2504
+ * @param {TODO} statement statement
2505
+ */
2450
2506
  blockPreWalkExportDefaultDeclaration(statement) {
2451
2507
  const prev = this.prevStatement;
2452
2508
  this.preWalkStatement(statement.declaration);
2453
2509
  this.prevStatement = prev;
2454
2510
  this.blockPreWalkStatement(statement.declaration);
2455
2511
  if (
2456
- statement.declaration.id &&
2512
+ /** @type {FunctionDeclaration | ClassDeclaration} */ (
2513
+ statement.declaration
2514
+ ).id &&
2457
2515
  statement.declaration.type !== "FunctionExpression" &&
2458
2516
  statement.declaration.type !== "ClassExpression"
2459
2517
  ) {
2518
+ const declaration =
2519
+ /** @type {FunctionDeclaration | ClassDeclaration} */
2520
+ (statement.declaration);
2460
2521
  this.hooks.exportSpecifier.call(
2461
2522
  statement,
2462
- statement.declaration.id.name,
2523
+ declaration.id.name,
2463
2524
  "default",
2464
2525
  undefined
2465
2526
  );
2466
2527
  }
2467
2528
  }
2468
2529
 
2530
+ /**
2531
+ * @param {ExportDefaultDeclaration} statement statement
2532
+ */
2469
2533
  walkExportDefaultDeclaration(statement) {
2470
2534
  this.hooks.export.call(statement);
2471
2535
  if (
2472
- statement.declaration.id &&
2536
+ /** @type {FunctionDeclaration | ClassDeclaration} */ (
2537
+ statement.declaration
2538
+ ).id &&
2473
2539
  statement.declaration.type !== "FunctionExpression" &&
2474
2540
  statement.declaration.type !== "ClassExpression"
2475
2541
  ) {
2476
- if (
2477
- !this.hooks.exportDeclaration.call(statement, statement.declaration)
2478
- ) {
2479
- this.walkStatement(statement.declaration);
2542
+ const declaration =
2543
+ /** @type {FunctionDeclaration | ClassDeclaration} */
2544
+ (statement.declaration);
2545
+ if (!this.hooks.exportDeclaration.call(statement, declaration)) {
2546
+ this.walkStatement(declaration);
2480
2547
  }
2481
2548
  } else {
2482
2549
  // Acorn parses `export default function() {}` as `FunctionDeclaration` and
@@ -2486,14 +2553,23 @@ class JavascriptParser extends Parser {
2486
2553
  statement.declaration.type === "FunctionDeclaration" ||
2487
2554
  statement.declaration.type === "ClassDeclaration"
2488
2555
  ) {
2489
- this.walkStatement(statement.declaration);
2556
+ this.walkStatement(
2557
+ /** @type {FunctionDeclaration | ClassDeclaration} */
2558
+ (statement.declaration)
2559
+ );
2490
2560
  } else {
2491
2561
  this.walkExpression(statement.declaration);
2492
2562
  }
2493
- if (!this.hooks.exportExpression.call(statement, statement.declaration)) {
2563
+
2564
+ if (
2565
+ !this.hooks.exportExpression.call(
2566
+ statement,
2567
+ /** @type {TODO} */ (statement).declaration
2568
+ )
2569
+ ) {
2494
2570
  this.hooks.exportSpecifier.call(
2495
2571
  statement,
2496
- statement.declaration,
2572
+ /** @type {TODO} */ (statement.declaration),
2497
2573
  "default",
2498
2574
  undefined
2499
2575
  );
@@ -2501,8 +2577,11 @@ class JavascriptParser extends Parser {
2501
2577
  }
2502
2578
  }
2503
2579
 
2580
+ /**
2581
+ * @param {ExportAllDeclaration} statement statement
2582
+ */
2504
2583
  blockPreWalkExportAllDeclaration(statement) {
2505
- const source = statement.source.value;
2584
+ const source = /** @type {ImportSource} */ (statement.source.value);
2506
2585
  const name = statement.exported ? statement.exported.name : null;
2507
2586
  this.hooks.exportImport.call(statement, source);
2508
2587
  this.hooks.exportImportSpecifier.call(statement, source, null, name, 0);
@@ -2556,30 +2635,43 @@ class JavascriptParser extends Parser {
2556
2635
 
2557
2636
  /**
2558
2637
  * @param {ObjectPattern} objectPattern object pattern
2559
- * @returns {Set<string> | undefined} set of names or undefined if not all keys are identifiers
2638
+ * @returns {Set<DestructuringAssignmentProperty> | undefined} set of names or undefined if not all keys are identifiers
2560
2639
  */
2561
2640
  _preWalkObjectPattern(objectPattern) {
2562
- const ids = new Set();
2641
+ /** @type {Set<DestructuringAssignmentProperty>} */
2642
+ const props = new Set();
2563
2643
  const properties = objectPattern.properties;
2564
2644
  for (let i = 0; i < properties.length; i++) {
2565
2645
  const property = properties[i];
2566
2646
  if (property.type !== "Property") return;
2647
+ if (property.shorthand && property.value.type === "Identifier") {
2648
+ this.scope.inShorthand = property.value.name;
2649
+ }
2567
2650
  const key = property.key;
2568
2651
  if (key.type === "Identifier") {
2569
- ids.add(key.name);
2652
+ props.add({
2653
+ id: key.name,
2654
+ range: key.range,
2655
+ shorthand: this.scope.inShorthand
2656
+ });
2570
2657
  } else {
2571
- const id = this.evaluateExpression(key);
2658
+ const id = this.evaluateExpression(/** @type {TODO} */ (key));
2572
2659
  const str = id.asString();
2573
2660
  if (str) {
2574
- ids.add(str);
2661
+ props.add({
2662
+ id: str,
2663
+ range: key.range,
2664
+ shorthand: this.scope.inShorthand
2665
+ });
2575
2666
  } else {
2576
2667
  // could not evaluate key
2577
2668
  return;
2578
2669
  }
2579
2670
  }
2671
+ this.scope.inShorthand = false;
2580
2672
  }
2581
2673
 
2582
- return ids;
2674
+ return props;
2583
2675
  }
2584
2676
 
2585
2677
  /**
@@ -2764,10 +2856,16 @@ class JavascriptParser extends Parser {
2764
2856
  this.walkPattern(pattern.left);
2765
2857
  }
2766
2858
 
2859
+ /**
2860
+ * @param {ObjectPattern} pattern pattern
2861
+ */
2767
2862
  walkObjectPattern(pattern) {
2768
2863
  for (let i = 0, len = pattern.properties.length; i < len; i++) {
2769
2864
  const prop = pattern.properties[i];
2770
2865
  if (prop) {
2866
+ if (prop.type === "RestElement") {
2867
+ continue;
2868
+ }
2771
2869
  if (prop.computed) this.walkExpression(prop.key);
2772
2870
  if (prop.value) this.walkPattern(prop.value);
2773
2871
  }
@@ -3248,9 +3346,21 @@ class JavascriptParser extends Parser {
3248
3346
  }
3249
3347
  }
3250
3348
 
3349
+ /**
3350
+ * @private
3351
+ * @param {FunctionExpression | ArrowFunctionExpression} functionExpression function expression
3352
+ * @param {(Expression | SpreadElement)[]} options options
3353
+ * @param {Expression | SpreadElement | null} currentThis current this
3354
+ */
3251
3355
  _walkIIFE(functionExpression, options, currentThis) {
3356
+ /**
3357
+ * @param {Expression | SpreadElement} argOrThis arg or this
3358
+ * @returns {string | VariableInfoInterface | undefined} var info
3359
+ */
3252
3360
  const getVarInfo = argOrThis => {
3253
- const renameIdentifier = this.getRenameIdentifier(argOrThis);
3361
+ const renameIdentifier = this.getRenameIdentifier(
3362
+ /** @type {Expression} */ (argOrThis)
3363
+ );
3254
3364
  if (renameIdentifier) {
3255
3365
  if (
3256
3366
  this.callHooksForInfo(
@@ -3267,7 +3377,7 @@ class JavascriptParser extends Parser {
3267
3377
  )
3268
3378
  ) {
3269
3379
  return typeof renameIdentifier === "string"
3270
- ? this.getVariableInfo(renameIdentifier)
3380
+ ? /** @type {string} */ (this.getVariableInfo(renameIdentifier))
3271
3381
  : renameIdentifier;
3272
3382
  }
3273
3383
  }
@@ -3280,12 +3390,15 @@ class JavascriptParser extends Parser {
3280
3390
  const varInfoForArgs = options.map(getVarInfo);
3281
3391
  const wasTopLevel = this.scope.topLevelScope;
3282
3392
  this.scope.topLevelScope = wasTopLevel && arrow ? "arrow" : false;
3283
- const scopeParams = params.filter(
3284
- (identifier, idx) => !varInfoForArgs[idx]
3285
- );
3393
+ const scopeParams =
3394
+ /** @type {(Identifier | string)[]} */
3395
+ (params.filter((identifier, idx) => !varInfoForArgs[idx]));
3286
3396
 
3287
3397
  // Add function name in scope for recursive calls
3288
- if (functionExpression.id) {
3398
+ if (
3399
+ functionExpression.type === "FunctionExpression" &&
3400
+ functionExpression.id
3401
+ ) {
3289
3402
  scopeParams.push(functionExpression.id.name);
3290
3403
  }
3291
3404
 
@@ -3297,7 +3410,7 @@ class JavascriptParser extends Parser {
3297
3410
  const varInfo = varInfoForArgs[i];
3298
3411
  if (!varInfo) continue;
3299
3412
  if (!params[i] || params[i].type !== "Identifier") continue;
3300
- this.setVariable(params[i].name, varInfo);
3413
+ this.setVariable(/** @type {Identifier} */ (params[i]).name, varInfo);
3301
3414
  }
3302
3415
  if (functionExpression.body.type === "BlockStatement") {
3303
3416
  this.detectMode(functionExpression.body.body);
@@ -3322,6 +3435,9 @@ class JavascriptParser extends Parser {
3322
3435
  this.walkExpression(expression.source);
3323
3436
  }
3324
3437
 
3438
+ /**
3439
+ * @param {CallExpression} expression expression
3440
+ */
3325
3441
  walkCallExpression(expression) {
3326
3442
  const isSimpleFunction = fn => {
3327
3443
  return fn.params.every(p => p.type === "Identifier");
@@ -3330,14 +3446,20 @@ class JavascriptParser extends Parser {
3330
3446
  expression.callee.type === "MemberExpression" &&
3331
3447
  expression.callee.object.type.endsWith("FunctionExpression") &&
3332
3448
  !expression.callee.computed &&
3449
+ // eslint-disable-next-line no-warning-comments
3450
+ // @ts-ignore
3451
+ // TODO check me and handle more cases
3333
3452
  (expression.callee.property.name === "call" ||
3453
+ // eslint-disable-next-line no-warning-comments
3454
+ // @ts-ignore
3334
3455
  expression.callee.property.name === "bind") &&
3335
3456
  expression.arguments.length > 0 &&
3336
3457
  isSimpleFunction(expression.callee.object)
3337
3458
  ) {
3338
3459
  // (function(…) { }.call/bind(?, …))
3339
3460
  this._walkIIFE(
3340
- expression.callee.object,
3461
+ /** @type {FunctionExpression | ArrowFunctionExpression} */
3462
+ (expression.callee.object),
3341
3463
  expression.arguments.slice(1),
3342
3464
  expression.arguments[0]
3343
3465
  );
@@ -3346,7 +3468,12 @@ class JavascriptParser extends Parser {
3346
3468
  isSimpleFunction(expression.callee)
3347
3469
  ) {
3348
3470
  // (function(…) { }(…))
3349
- this._walkIIFE(expression.callee, expression.arguments, null);
3471
+ this._walkIIFE(
3472
+ /** @type {FunctionExpression | ArrowFunctionExpression} */
3473
+ (expression.callee),
3474
+ expression.arguments,
3475
+ null
3476
+ );
3350
3477
  } else {
3351
3478
  if (expression.callee.type === "MemberExpression") {
3352
3479
  const exprInfo = this.getMemberExpressionInfo(
@@ -3366,7 +3493,9 @@ class JavascriptParser extends Parser {
3366
3493
  if (result === true) return;
3367
3494
  }
3368
3495
  }
3369
- const callee = this.evaluateExpression(expression.callee);
3496
+ const callee = this.evaluateExpression(
3497
+ /** @type {TODO} */ (expression.callee)
3498
+ );
3370
3499
  if (callee.isIdentifier()) {
3371
3500
  const result1 = this.callHooksForInfo(
3372
3501
  this.hooks.callMemberChain,
@@ -3824,8 +3953,8 @@ class JavascriptParser extends Parser {
3824
3953
  }
3825
3954
 
3826
3955
  /**
3827
- * @param {(Pattern | Property)[]} patterns patterns
3828
- * @param {TODO} onIdent on ident callback
3956
+ * @param {(string | Pattern | Property)[]} patterns patterns
3957
+ * @param {OnIdent} onIdent on ident callback
3829
3958
  */
3830
3959
  enterPatterns(patterns, onIdent) {
3831
3960
  for (const pattern of patterns) {
@@ -3839,7 +3968,7 @@ class JavascriptParser extends Parser {
3839
3968
 
3840
3969
  /**
3841
3970
  * @param {Pattern | Property} pattern pattern
3842
- * @param {TODO} onIdent on ident callback
3971
+ * @param {OnIdent} onIdent on ident callback
3843
3972
  */
3844
3973
  enterPattern(pattern, onIdent) {
3845
3974
  if (!pattern) return;
@@ -3873,7 +4002,7 @@ class JavascriptParser extends Parser {
3873
4002
 
3874
4003
  /**
3875
4004
  * @param {Identifier} pattern identifier pattern
3876
- * @param {TODO} onIdent callback
4005
+ * @param {OnIdent} onIdent callback
3877
4006
  */
3878
4007
  enterIdentifier(pattern, onIdent) {
3879
4008
  if (!this.callHooksForName(this.hooks.pattern, pattern.name, pattern)) {
@@ -3883,7 +4012,7 @@ class JavascriptParser extends Parser {
3883
4012
 
3884
4013
  /**
3885
4014
  * @param {ObjectPattern} pattern object pattern
3886
- * @param {TODO} onIdent callback
4015
+ * @param {OnIdent} onIdent callback
3887
4016
  */
3888
4017
  enterObjectPattern(pattern, onIdent) {
3889
4018
  for (
@@ -3898,7 +4027,7 @@ class JavascriptParser extends Parser {
3898
4027
 
3899
4028
  /**
3900
4029
  * @param {ArrayPattern} pattern object pattern
3901
- * @param {TODO} onIdent callback
4030
+ * @param {OnIdent} onIdent callback
3902
4031
  */
3903
4032
  enterArrayPattern(pattern, onIdent) {
3904
4033
  for (
@@ -3916,7 +4045,7 @@ class JavascriptParser extends Parser {
3916
4045
 
3917
4046
  /**
3918
4047
  * @param {RestElement} pattern object pattern
3919
- * @param {TODO} onIdent callback
4048
+ * @param {OnIdent} onIdent callback
3920
4049
  */
3921
4050
  enterRestElement(pattern, onIdent) {
3922
4051
  this.enterPattern(pattern.argument, onIdent);
@@ -3924,7 +4053,7 @@ class JavascriptParser extends Parser {
3924
4053
 
3925
4054
  /**
3926
4055
  * @param {AssignmentPattern} pattern object pattern
3927
- * @param {TODO} onIdent callback
4056
+ * @param {OnIdent} onIdent callback
3928
4057
  */
3929
4058
  enterAssignmentPattern(pattern, onIdent) {
3930
4059
  this.enterPattern(pattern.left, onIdent);
@@ -3975,6 +4104,10 @@ class JavascriptParser extends Parser {
3975
4104
  );
3976
4105
  }
3977
4106
 
4107
+ /**
4108
+ * @param {Expression} expression expression
4109
+ * @returns {TODO} result
4110
+ */
3978
4111
  parseCalculatedString(expression) {
3979
4112
  switch (expression.type) {
3980
4113
  case "BinaryExpression":
@@ -4412,7 +4545,7 @@ class JavascriptParser extends Parser {
4412
4545
 
4413
4546
  /**
4414
4547
  * @param {string} name variable name
4415
- * @returns {ExportedVariableInfo} info for this variable
4548
+ * @returns {string | ExportedVariableInfo} info for this variable
4416
4549
  */
4417
4550
  getVariableInfo(name) {
4418
4551
  const value = this.scope.definitions.get(name);
@@ -4425,7 +4558,7 @@ class JavascriptParser extends Parser {
4425
4558
 
4426
4559
  /**
4427
4560
  * @param {string} name variable name
4428
- * @param {ExportedVariableInfo} variableInfo new info for this variable
4561
+ * @param {string | ExportedVariableInfo} variableInfo new info for this variable
4429
4562
  * @returns {void}
4430
4563
  */
4431
4564
  setVariable(name, variableInfo) {