webpack 5.83.1 → 5.84.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 (137) hide show
  1. package/README.md +2 -2
  2. package/lib/CompatibilityPlugin.js +3 -2
  3. package/lib/Compilation.js +2 -2
  4. package/lib/ContextModule.js +3 -3
  5. package/lib/DefinePlugin.js +11 -2
  6. package/lib/DllEntryPlugin.js +5 -0
  7. package/lib/DllModule.js +1 -1
  8. package/lib/EvalSourceMapDevToolPlugin.js +3 -1
  9. package/lib/MainTemplate.js +2 -2
  10. package/lib/PrefetchPlugin.js +4 -0
  11. package/lib/RuntimeTemplate.js +5 -5
  12. package/lib/SelfModuleFactory.js +12 -0
  13. package/lib/SourceMapDevToolPlugin.js +9 -2
  14. package/lib/Template.js +2 -1
  15. package/lib/config/browserslistTargetHandler.js +3 -3
  16. package/lib/config/defaults.js +209 -70
  17. package/lib/config/normalization.js +103 -71
  18. package/lib/config/target.js +37 -10
  19. package/lib/container/FallbackModule.js +1 -1
  20. package/lib/container/RemoteRuntimeModule.js +1 -1
  21. package/lib/css/CssParser.js +168 -73
  22. package/lib/debug/ProfilingPlugin.js +11 -0
  23. package/lib/dependencies/AMDDefineDependency.js +12 -6
  24. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +8 -2
  25. package/lib/dependencies/AMDPlugin.js +7 -0
  26. package/lib/dependencies/AMDRequireArrayDependency.js +5 -0
  27. package/lib/dependencies/AMDRequireContextDependency.js +6 -0
  28. package/lib/dependencies/AMDRequireDependenciesBlock.js +6 -0
  29. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +8 -2
  30. package/lib/dependencies/AMDRequireDependency.js +8 -1
  31. package/lib/dependencies/AMDRequireItemDependency.js +6 -0
  32. package/lib/dependencies/CachedConstDependency.js +6 -0
  33. package/lib/dependencies/CommonJsExportRequireDependency.js +11 -0
  34. package/lib/dependencies/CommonJsExportsDependency.js +8 -0
  35. package/lib/dependencies/CommonJsExportsParserPlugin.js +2 -2
  36. package/lib/dependencies/CommonJsFullRequireDependency.js +2 -1
  37. package/lib/dependencies/CommonJsPlugin.js +14 -0
  38. package/lib/dependencies/CommonJsRequireContextDependency.js +8 -0
  39. package/lib/dependencies/CommonJsRequireDependency.js +7 -0
  40. package/lib/dependencies/CommonJsSelfReferenceDependency.js +8 -0
  41. package/lib/dependencies/ConstDependency.js +2 -1
  42. package/lib/dependencies/ContextDependencyHelpers.js +3 -3
  43. package/lib/dependencies/CreateScriptUrlDependency.js +2 -1
  44. package/lib/dependencies/CriticalDependencyWarning.js +3 -0
  45. package/lib/dependencies/CssImportDependency.js +2 -1
  46. package/lib/dependencies/CssLocalIdentifierDependency.js +2 -1
  47. package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
  48. package/lib/dependencies/CssUrlDependency.js +12 -2
  49. package/lib/dependencies/DelegatedSourceDependency.js +3 -0
  50. package/lib/dependencies/ExportsInfoDependency.js +6 -0
  51. package/lib/dependencies/HarmonyAcceptDependency.js +2 -1
  52. package/lib/dependencies/HarmonyAcceptImportDependency.js +3 -0
  53. package/lib/dependencies/HarmonyDetectionParserPlugin.js +16 -0
  54. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +11 -0
  55. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +3 -0
  56. package/lib/dependencies/HarmonyExportExpressionDependency.js +8 -0
  57. package/lib/dependencies/HarmonyExportHeaderDependency.js +5 -0
  58. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +2 -1
  59. package/lib/dependencies/HarmonyExportSpecifierDependency.js +4 -0
  60. package/lib/dependencies/HarmonyImportDependency.js +2 -1
  61. package/lib/dependencies/HarmonyImportSideEffectDependency.js +6 -0
  62. package/lib/dependencies/HarmonyImportSpecifierDependency.js +11 -0
  63. package/lib/dependencies/HarmonyModulesPlugin.js +12 -0
  64. package/lib/dependencies/ImportContextDependency.js +6 -0
  65. package/lib/dependencies/ImportDependency.js +2 -1
  66. package/lib/dependencies/ImportEagerDependency.js +2 -1
  67. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +32 -13
  68. package/lib/dependencies/ImportMetaContextPlugin.js +7 -0
  69. package/lib/dependencies/ImportMetaHotAcceptDependency.js +6 -0
  70. package/lib/dependencies/ImportMetaHotDeclineDependency.js +6 -0
  71. package/lib/dependencies/ImportParserPlugin.js +5 -0
  72. package/lib/dependencies/ImportPlugin.js +7 -0
  73. package/lib/dependencies/ImportWeakDependency.js +2 -1
  74. package/lib/dependencies/LocalModule.js +16 -0
  75. package/lib/dependencies/LocalModuleDependency.js +7 -0
  76. package/lib/dependencies/LocalModulesHelpers.js +18 -0
  77. package/lib/dependencies/ModuleHotAcceptDependency.js +6 -0
  78. package/lib/dependencies/ModuleHotDeclineDependency.js +6 -0
  79. package/lib/dependencies/PrefetchDependency.js +3 -0
  80. package/lib/dependencies/ProvidedDependency.js +2 -1
  81. package/lib/dependencies/PureExpressionDependency.js +2 -1
  82. package/lib/dependencies/RequireContextDependency.js +6 -0
  83. package/lib/dependencies/RequireContextPlugin.js +7 -0
  84. package/lib/dependencies/RequireEnsureDependenciesBlock.js +4 -0
  85. package/lib/dependencies/RequireEnsureDependency.js +8 -2
  86. package/lib/dependencies/RequireEnsureItemDependency.js +3 -0
  87. package/lib/dependencies/RequireEnsurePlugin.js +14 -0
  88. package/lib/dependencies/RequireHeaderDependency.js +5 -1
  89. package/lib/dependencies/RequireIncludeDependency.js +5 -0
  90. package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +3 -0
  91. package/lib/dependencies/RequireIncludePlugin.js +14 -0
  92. package/lib/dependencies/RequireResolveContextDependency.js +8 -0
  93. package/lib/dependencies/RequireResolveDependency.js +6 -0
  94. package/lib/dependencies/RequireResolveHeaderDependency.js +4 -0
  95. package/lib/dependencies/SystemPlugin.js +10 -1
  96. package/lib/dependencies/URLDependency.js +3 -2
  97. package/lib/dependencies/URLPlugin.js +7 -5
  98. package/lib/dependencies/UnsupportedDependency.js +5 -0
  99. package/lib/dependencies/WebAssemblyExportImportedDependency.js +6 -0
  100. package/lib/dependencies/WebpackIsIncludedDependency.js +5 -0
  101. package/lib/dependencies/WorkerDependency.js +2 -1
  102. package/lib/dependencies/WorkerPlugin.js +5 -2
  103. package/lib/dependencies/getFunctionExpression.js +7 -0
  104. package/lib/esm/ExportWebpackRequireRuntimeModule.js +2 -1
  105. package/lib/esm/ModuleChunkFormatPlugin.js +2 -2
  106. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +5 -2
  107. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +2 -2
  108. package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -1
  109. package/lib/javascript/JavascriptModulesPlugin.js +13 -13
  110. package/lib/javascript/JavascriptParser.js +540 -180
  111. package/lib/javascript/StartupHelpers.js +1 -1
  112. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
  113. package/lib/node/RequireChunkLoadingRuntimeModule.js +2 -2
  114. package/lib/optimize/ConcatenatedModule.js +1 -1
  115. package/lib/optimize/InnerGraphPlugin.js +11 -4
  116. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -1
  117. package/lib/runtime/StartupEntrypointRuntimeModule.js +5 -5
  118. package/lib/serialization/ArraySerializer.js +22 -6
  119. package/lib/serialization/BinaryMiddleware.js +21 -0
  120. package/lib/serialization/DateObjectSerializer.js +15 -4
  121. package/lib/serialization/ErrorObjectSerializer.js +20 -8
  122. package/lib/serialization/FileMiddleware.js +17 -0
  123. package/lib/serialization/MapObjectSerializer.js +24 -8
  124. package/lib/serialization/NullPrototypeObjectSerializer.js +25 -8
  125. package/lib/serialization/ObjectMiddleware.js +23 -0
  126. package/lib/serialization/PlainObjectSerializer.js +23 -12
  127. package/lib/serialization/RegExpObjectSerializer.js +16 -5
  128. package/lib/serialization/SetObjectSerializer.js +21 -6
  129. package/lib/sharing/ShareRuntimeModule.js +1 -1
  130. package/lib/util/makeSerializable.js +7 -0
  131. package/lib/util/serialization.js +10 -0
  132. package/lib/web/JsonpChunkLoadingRuntimeModule.js +4 -1
  133. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +5 -1
  134. package/package.json +3 -3
  135. package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
  136. package/schemas/plugins/SourceMapDevToolPlugin.json +4 -0
  137. package/types.d.ts +469 -149
@@ -16,43 +16,77 @@ const memoize = require("../util/memoize");
16
16
  const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
17
17
 
18
18
  /** @typedef {import("acorn").Options} AcornOptions */
19
- /** @typedef {import("estree").ArrayExpression} ArrayExpressionNode */
20
- /** @typedef {import("estree").BinaryExpression} BinaryExpressionNode */
21
- /** @typedef {import("estree").BlockStatement} BlockStatementNode */
22
- /** @typedef {import("estree").SequenceExpression} SequenceExpressionNode */
23
- /** @typedef {import("estree").CallExpression} CallExpressionNode */
24
- /** @typedef {import("estree").ClassDeclaration} ClassDeclarationNode */
25
- /** @typedef {import("estree").ClassExpression} ClassExpressionNode */
26
- /** @typedef {import("estree").Comment} CommentNode */
27
- /** @typedef {import("estree").ConditionalExpression} ConditionalExpressionNode */
28
- /** @typedef {import("estree").Declaration} DeclarationNode */
29
- /** @typedef {import("estree").PrivateIdentifier} PrivateIdentifierNode */
30
- /** @typedef {import("estree").PropertyDefinition} PropertyDefinitionNode */
31
- /** @typedef {import("estree").Expression} ExpressionNode */
32
- /** @typedef {import("estree").Identifier} IdentifierNode */
33
- /** @typedef {import("estree").IfStatement} IfStatementNode */
34
- /** @typedef {import("estree").LabeledStatement} LabeledStatementNode */
35
- /** @typedef {import("estree").Literal} LiteralNode */
36
- /** @typedef {import("estree").LogicalExpression} LogicalExpressionNode */
37
- /** @typedef {import("estree").ChainExpression} ChainExpressionNode */
38
- /** @typedef {import("estree").MemberExpression} MemberExpressionNode */
39
- /** @typedef {import("estree").MetaProperty} MetaPropertyNode */
40
- /** @typedef {import("estree").MethodDefinition} MethodDefinitionNode */
41
- /** @typedef {import("estree").ModuleDeclaration} ModuleDeclarationNode */
42
- /** @typedef {import("estree").NewExpression} NewExpressionNode */
19
+ /** @typedef {import("estree").AssignmentExpression} AssignmentExpression */
20
+ /** @typedef {import("estree").BinaryExpression} BinaryExpression */
21
+ /** @typedef {import("estree").BlockStatement} BlockStatement */
22
+ /** @typedef {import("estree").SequenceExpression} SequenceExpression */
23
+ /** @typedef {import("estree").CallExpression} CallExpression */
24
+ /** @typedef {import("estree").BaseCallExpression} BaseCallExpression */
25
+ /** @typedef {import("estree").StaticBlock} StaticBlock */
26
+ /** @typedef {import("estree").ImportExpression} ImportExpression */
27
+ /** @typedef {import("estree").ClassDeclaration} ClassDeclaration */
28
+ /** @typedef {import("estree").ForStatement} ForStatement */
29
+ /** @typedef {import("estree").SwitchStatement} SwitchStatement */
30
+ /** @typedef {import("estree").ExportNamedDeclaration} ExportNamedDeclaration */
31
+ /** @typedef {import("estree").ClassExpression} ClassExpression */
32
+ /** @typedef {import("estree").Comment} Comment */
33
+ /** @typedef {import("estree").ConditionalExpression} ConditionalExpression */
34
+ /** @typedef {import("estree").Declaration} Declaration */
35
+ /** @typedef {import("estree").PrivateIdentifier} PrivateIdentifier */
36
+ /** @typedef {import("estree").PropertyDefinition} PropertyDefinition */
37
+ /** @typedef {import("estree").Expression} Expression */
38
+ /** @typedef {import("estree").Identifier} Identifier */
39
+ /** @typedef {import("estree").VariableDeclaration} VariableDeclaration */
40
+ /** @typedef {import("estree").IfStatement} IfStatement */
41
+ /** @typedef {import("estree").LabeledStatement} LabeledStatement */
42
+ /** @typedef {import("estree").Literal} Literal */
43
+ /** @typedef {import("estree").LogicalExpression} LogicalExpression */
44
+ /** @typedef {import("estree").ChainExpression} ChainExpression */
45
+ /** @typedef {import("estree").MemberExpression} MemberExpression */
46
+ /** @typedef {import("estree").YieldExpression} YieldExpression */
47
+ /** @typedef {import("estree").MetaProperty} MetaProperty */
48
+ /** @typedef {import("estree").Property} Property */
49
+ /** @typedef {import("estree").AssignmentPattern} AssignmentPattern */
50
+ /** @typedef {import("estree").Pattern} Pattern */
51
+ /** @typedef {import("estree").UpdateExpression} UpdateExpression */
52
+ /** @typedef {import("estree").ObjectExpression} ObjectExpression */
53
+ /** @typedef {import("estree").UnaryExpression} UnaryExpression */
54
+ /** @typedef {import("estree").ArrayExpression} ArrayExpression */
55
+ /** @typedef {import("estree").ArrayPattern} ArrayPattern */
56
+ /** @typedef {import("estree").AwaitExpression} AwaitExpression */
57
+ /** @typedef {import("estree").ThisExpression} ThisExpression */
58
+ /** @typedef {import("estree").RestElement} RestElement */
59
+ /** @typedef {import("estree").ObjectPattern} ObjectPattern */
60
+ /** @typedef {import("estree").SwitchCase} SwitchCase */
61
+ /** @typedef {import("estree").CatchClause} CatchClause */
62
+ /** @typedef {import("estree").VariableDeclarator} VariableDeclarator */
63
+ /** @typedef {import("estree").ForInStatement} ForInStatement */
64
+ /** @typedef {import("estree").ForOfStatement} ForOfStatement */
65
+ /** @typedef {import("estree").ReturnStatement} ReturnStatement */
66
+ /** @typedef {import("estree").WithStatement} WithStatement */
67
+ /** @typedef {import("estree").ThrowStatement} ThrowStatement */
68
+ /** @typedef {import("estree").MethodDefinition} MethodDefinition */
69
+ /** @typedef {import("estree").ModuleDeclaration} ModuleDeclaration */
70
+ /** @typedef {import("estree").NewExpression} NewExpression */
71
+ /** @typedef {import("estree").SpreadElement} SpreadElement */
72
+ /** @typedef {import("estree").FunctionExpression} FunctionExpression */
73
+ /** @typedef {import("estree").WhileStatement} WhileStatement */
74
+ /** @typedef {import("estree").ArrowFunctionExpression} ArrowFunctionExpression */
75
+ /** @typedef {import("estree").ExpressionStatement} ExpressionStatement */
76
+ /** @typedef {import("estree").FunctionDeclaration} FunctionDeclaration */
77
+ /** @typedef {import("estree").DoWhileStatement} DoWhileStatement */
78
+ /** @typedef {import("estree").TryStatement} TryStatement */
43
79
  /** @typedef {import("estree").Node} AnyNode */
44
- /** @typedef {import("estree").Program} ProgramNode */
45
- /** @typedef {import("estree").Statement} StatementNode */
46
- /** @typedef {import("estree").ImportDeclaration} ImportDeclarationNode */
47
- /** @typedef {import("estree").ExportNamedDeclaration} ExportNamedDeclarationNode */
48
- /** @typedef {import("estree").ExportDefaultDeclaration} ExportDefaultDeclarationNode */
49
- /** @typedef {import("estree").ExportAllDeclaration} ExportAllDeclarationNode */
50
- /** @typedef {import("estree").Super} SuperNode */
51
- /** @typedef {import("estree").TaggedTemplateExpression} TaggedTemplateExpressionNode */
52
- /** @typedef {import("estree").TemplateLiteral} TemplateLiteralNode */
53
- /** @typedef {import("estree").ThisExpression} ThisExpressionNode */
54
- /** @typedef {import("estree").UnaryExpression} UnaryExpressionNode */
55
- /** @typedef {import("estree").VariableDeclarator} VariableDeclaratorNode */
80
+ /** @typedef {import("estree").Program} Program */
81
+ /** @typedef {import("estree").Directive} Directive */
82
+ /** @typedef {import("estree").Statement} Statement */
83
+ /** @typedef {import("estree").ImportDeclaration} ImportDeclaration */
84
+ /** @typedef {import("estree").ExportDefaultDeclaration} ExportDefaultDeclaration */
85
+ /** @typedef {import("estree").ExportAllDeclaration} ExportAllDeclaration */
86
+ /** @typedef {import("estree").Super} Super */
87
+ /** @typedef {import("estree").TaggedTemplateExpression} TaggedTemplateExpression */
88
+ /** @typedef {import("estree").TemplateLiteral} TemplateLiteral */
89
+ /** @typedef {Record<string, any>} Assertions */
56
90
  /** @template T @typedef {import("tapable").AsArray<T>} AsArray<T> */
57
91
  /** @typedef {import("../Parser").ParserState} ParserState */
58
92
  /** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
@@ -82,7 +116,7 @@ class VariableInfo {
82
116
  }
83
117
 
84
118
  /** @typedef {string | ScopeInfo | VariableInfo} ExportedVariableInfo */
85
- /** @typedef {LiteralNode | string | null | undefined} ImportSource */
119
+ /** @typedef {Literal | string | null | undefined} ImportSource */
86
120
  /** @typedef {Omit<AcornOptions, "sourceType" | "ecmaVersion"> & { sourceType: "module" | "script" | "auto", ecmaVersion?: AcornOptions["ecmaVersion"] }} ParseOptions */
87
121
 
88
122
  /**
@@ -96,12 +130,14 @@ class VariableInfo {
96
130
  * @typedef {Object} ScopeInfo
97
131
  * @property {StackedMap<string, VariableInfo | ScopeInfo>} definitions
98
132
  * @property {boolean | "arrow"} topLevelScope
99
- * @property {boolean} inShorthand
133
+ * @property {boolean | string} inShorthand
100
134
  * @property {boolean} isStrict
101
135
  * @property {boolean} isAsmJs
102
136
  * @property {boolean} inTry
103
137
  */
104
138
 
139
+ /** @typedef {[number, number]} Range */
140
+
105
141
  /**
106
142
  * Helper function for joining two ranges into a single range. This is useful
107
143
  * when working with AST nodes, as it allows you to combine the ranges of child nodes
@@ -157,7 +193,7 @@ const objectAndMembersToName = (object, membersReversed) => {
157
193
  * [MetaProperties](https://github.com/estree/estree/blob/master/es2015.md#metaproperty) which is
158
194
  * specifically for handling the `new.target` meta property.
159
195
  *
160
- * @param {ExpressionNode | SuperNode} expression expression
196
+ * @param {Expression | Super} expression expression
161
197
  * @returns {string | "this" | undefined} name or variable info
162
198
  */
163
199
  const getRootName = expression => {
@@ -199,81 +235,81 @@ class JavascriptParser extends Parser {
199
235
  constructor(sourceType = "auto") {
200
236
  super();
201
237
  this.hooks = Object.freeze({
202
- /** @type {HookMap<SyncBailHook<[UnaryExpressionNode], BasicEvaluatedExpression | undefined | null>>} */
238
+ /** @type {HookMap<SyncBailHook<[UnaryExpression], BasicEvaluatedExpression | undefined | null>>} */
203
239
  evaluateTypeof: new HookMap(() => new SyncBailHook(["expression"])),
204
- /** @type {HookMap<SyncBailHook<[ExpressionNode], BasicEvaluatedExpression | undefined | null>>} */
240
+ /** @type {HookMap<SyncBailHook<[Expression], BasicEvaluatedExpression | undefined | null>>} */
205
241
  evaluate: new HookMap(() => new SyncBailHook(["expression"])),
206
- /** @type {HookMap<SyncBailHook<[IdentifierNode | ThisExpressionNode | MemberExpressionNode | MetaPropertyNode], BasicEvaluatedExpression | undefined | null>>} */
242
+ /** @type {HookMap<SyncBailHook<[Identifier | ThisExpression | MemberExpression | MetaProperty], BasicEvaluatedExpression | undefined | null>>} */
207
243
  evaluateIdentifier: new HookMap(() => new SyncBailHook(["expression"])),
208
- /** @type {HookMap<SyncBailHook<[IdentifierNode | ThisExpressionNode | MemberExpressionNode], BasicEvaluatedExpression | undefined | null>>} */
244
+ /** @type {HookMap<SyncBailHook<[Identifier | ThisExpression | MemberExpression], BasicEvaluatedExpression | undefined | null>>} */
209
245
  evaluateDefinedIdentifier: new HookMap(
210
246
  () => new SyncBailHook(["expression"])
211
247
  ),
212
- /** @type {HookMap<SyncBailHook<[NewExpressionNode], BasicEvaluatedExpression | undefined | null>>} */
248
+ /** @type {HookMap<SyncBailHook<[NewExpression], BasicEvaluatedExpression | undefined | null>>} */
213
249
  evaluateNewExpression: new HookMap(
214
250
  () => new SyncBailHook(["expression"])
215
251
  ),
216
- /** @type {HookMap<SyncBailHook<[CallExpressionNode], BasicEvaluatedExpression | undefined | null>>} */
252
+ /** @type {HookMap<SyncBailHook<[CallExpression], BasicEvaluatedExpression | undefined | null>>} */
217
253
  evaluateCallExpression: new HookMap(
218
254
  () => new SyncBailHook(["expression"])
219
255
  ),
220
- /** @type {HookMap<SyncBailHook<[CallExpressionNode, BasicEvaluatedExpression | undefined], BasicEvaluatedExpression | undefined | null>>} */
256
+ /** @type {HookMap<SyncBailHook<[CallExpression, BasicEvaluatedExpression | undefined], BasicEvaluatedExpression | undefined | null>>} */
221
257
  evaluateCallExpressionMember: new HookMap(
222
258
  () => new SyncBailHook(["expression", "param"])
223
259
  ),
224
- /** @type {HookMap<SyncBailHook<[ExpressionNode | DeclarationNode | PrivateIdentifierNode, number], boolean | void>>} */
260
+ /** @type {HookMap<SyncBailHook<[Expression | Declaration | PrivateIdentifier, number], boolean | void>>} */
225
261
  isPure: new HookMap(
226
262
  () => new SyncBailHook(["expression", "commentsStartPosition"])
227
263
  ),
228
- /** @type {SyncBailHook<[StatementNode | ModuleDeclarationNode], boolean | void>} */
264
+ /** @type {SyncBailHook<[Statement | ModuleDeclaration], boolean | void>} */
229
265
  preStatement: new SyncBailHook(["statement"]),
230
266
 
231
- /** @type {SyncBailHook<[StatementNode | ModuleDeclarationNode], boolean | void>} */
267
+ /** @type {SyncBailHook<[Statement | ModuleDeclaration], boolean | void>} */
232
268
  blockPreStatement: new SyncBailHook(["declaration"]),
233
- /** @type {SyncBailHook<[StatementNode | ModuleDeclarationNode], boolean | void>} */
269
+ /** @type {SyncBailHook<[Statement | ModuleDeclaration], boolean | void>} */
234
270
  statement: new SyncBailHook(["statement"]),
235
- /** @type {SyncBailHook<[IfStatementNode], boolean | void>} */
271
+ /** @type {SyncBailHook<[IfStatement], boolean | void>} */
236
272
  statementIf: new SyncBailHook(["statement"]),
237
- /** @type {SyncBailHook<[ExpressionNode, ClassExpressionNode | ClassDeclarationNode], boolean | void>} */
273
+ /** @type {SyncBailHook<[Expression, ClassExpression | ClassDeclaration], boolean | void>} */
238
274
  classExtendsExpression: new SyncBailHook([
239
275
  "expression",
240
276
  "classDefinition"
241
277
  ]),
242
- /** @type {SyncBailHook<[MethodDefinitionNode | PropertyDefinitionNode, ClassExpressionNode | ClassDeclarationNode], boolean | void>} */
278
+ /** @type {SyncBailHook<[MethodDefinition | PropertyDefinition | StaticBlock, ClassExpression | ClassDeclaration], boolean | void>} */
243
279
  classBodyElement: new SyncBailHook(["element", "classDefinition"]),
244
- /** @type {SyncBailHook<[ExpressionNode, MethodDefinitionNode | PropertyDefinitionNode, ClassExpressionNode | ClassDeclarationNode], boolean | void>} */
280
+ /** @type {SyncBailHook<[Expression, MethodDefinition | PropertyDefinition, ClassExpression | ClassDeclaration], boolean | void>} */
245
281
  classBodyValue: new SyncBailHook([
246
282
  "expression",
247
283
  "element",
248
284
  "classDefinition"
249
285
  ]),
250
- /** @type {HookMap<SyncBailHook<[LabeledStatementNode], boolean | void>>} */
286
+ /** @type {HookMap<SyncBailHook<[LabeledStatement], boolean | void>>} */
251
287
  label: new HookMap(() => new SyncBailHook(["statement"])),
252
- /** @type {SyncBailHook<[ImportDeclarationNode, ImportSource], boolean | void>} */
288
+ /** @type {SyncBailHook<[ImportDeclaration, ImportSource], boolean | void>} */
253
289
  import: new SyncBailHook(["statement", "source"]),
254
- /** @type {SyncBailHook<[ImportDeclarationNode, ImportSource, string, string], boolean | void>} */
290
+ /** @type {SyncBailHook<[ImportDeclaration, ImportSource, string, string], boolean | void>} */
255
291
  importSpecifier: new SyncBailHook([
256
292
  "statement",
257
293
  "source",
258
294
  "exportName",
259
295
  "identifierName"
260
296
  ]),
261
- /** @type {SyncBailHook<[ExportNamedDeclarationNode | ExportAllDeclarationNode], boolean | void>} */
297
+ /** @type {SyncBailHook<[ExportNamedDeclaration | ExportAllDeclaration], boolean | void>} */
262
298
  export: new SyncBailHook(["statement"]),
263
- /** @type {SyncBailHook<[ExportNamedDeclarationNode | ExportAllDeclarationNode, ImportSource], boolean | void>} */
299
+ /** @type {SyncBailHook<[ExportNamedDeclaration | ExportAllDeclaration, ImportSource], boolean | void>} */
264
300
  exportImport: new SyncBailHook(["statement", "source"]),
265
- /** @type {SyncBailHook<[ExportNamedDeclarationNode | ExportAllDeclarationNode, DeclarationNode], boolean | void>} */
301
+ /** @type {SyncBailHook<[ExportNamedDeclaration | ExportAllDeclaration, Declaration], boolean | void>} */
266
302
  exportDeclaration: new SyncBailHook(["statement", "declaration"]),
267
- /** @type {SyncBailHook<[ExportDefaultDeclarationNode, DeclarationNode], boolean | void>} */
303
+ /** @type {SyncBailHook<[ExportDefaultDeclaration, Declaration], boolean | void>} */
268
304
  exportExpression: new SyncBailHook(["statement", "declaration"]),
269
- /** @type {SyncBailHook<[ExportNamedDeclarationNode | ExportAllDeclarationNode, string, string, number | undefined], boolean | void>} */
305
+ /** @type {SyncBailHook<[ExportNamedDeclaration | ExportAllDeclaration, string, string, number | undefined], boolean | void>} */
270
306
  exportSpecifier: new SyncBailHook([
271
307
  "statement",
272
308
  "identifierName",
273
309
  "exportName",
274
310
  "index"
275
311
  ]),
276
- /** @type {SyncBailHook<[ExportNamedDeclarationNode | ExportAllDeclarationNode, ImportSource, string, string, number | undefined], boolean | void>} */
312
+ /** @type {SyncBailHook<[ExportNamedDeclaration | ExportAllDeclaration, ImportSource, string, string, number | undefined], boolean | void>} */
277
313
  exportImportSpecifier: new SyncBailHook([
278
314
  "statement",
279
315
  "source",
@@ -281,45 +317,45 @@ class JavascriptParser extends Parser {
281
317
  "exportName",
282
318
  "index"
283
319
  ]),
284
- /** @type {SyncBailHook<[VariableDeclaratorNode, StatementNode], boolean | void>} */
320
+ /** @type {SyncBailHook<[VariableDeclarator, Statement], boolean | void>} */
285
321
  preDeclarator: new SyncBailHook(["declarator", "statement"]),
286
- /** @type {SyncBailHook<[VariableDeclaratorNode, StatementNode], boolean | void>} */
322
+ /** @type {SyncBailHook<[VariableDeclarator, Statement], boolean | void>} */
287
323
  declarator: new SyncBailHook(["declarator", "statement"]),
288
- /** @type {HookMap<SyncBailHook<[DeclarationNode], boolean | void>>} */
324
+ /** @type {HookMap<SyncBailHook<[Declaration], boolean | void>>} */
289
325
  varDeclaration: new HookMap(() => new SyncBailHook(["declaration"])),
290
- /** @type {HookMap<SyncBailHook<[DeclarationNode], boolean | void>>} */
326
+ /** @type {HookMap<SyncBailHook<[Declaration], boolean | void>>} */
291
327
  varDeclarationLet: new HookMap(() => new SyncBailHook(["declaration"])),
292
- /** @type {HookMap<SyncBailHook<[DeclarationNode], boolean | void>>} */
328
+ /** @type {HookMap<SyncBailHook<[Declaration], boolean | void>>} */
293
329
  varDeclarationConst: new HookMap(() => new SyncBailHook(["declaration"])),
294
- /** @type {HookMap<SyncBailHook<[DeclarationNode], boolean | void>>} */
330
+ /** @type {HookMap<SyncBailHook<[Declaration], boolean | void>>} */
295
331
  varDeclarationVar: new HookMap(() => new SyncBailHook(["declaration"])),
296
- /** @type {HookMap<SyncBailHook<[IdentifierNode], boolean | void>>} */
332
+ /** @type {HookMap<SyncBailHook<[Identifier], boolean | void>>} */
297
333
  pattern: new HookMap(() => new SyncBailHook(["pattern"])),
298
- /** @type {HookMap<SyncBailHook<[ExpressionNode], boolean | void>>} */
334
+ /** @type {HookMap<SyncBailHook<[Expression], boolean | void>>} */
299
335
  canRename: new HookMap(() => new SyncBailHook(["initExpression"])),
300
- /** @type {HookMap<SyncBailHook<[ExpressionNode], boolean | void>>} */
336
+ /** @type {HookMap<SyncBailHook<[Expression], boolean | void>>} */
301
337
  rename: new HookMap(() => new SyncBailHook(["initExpression"])),
302
- /** @type {HookMap<SyncBailHook<[import("estree").AssignmentExpression], boolean | void>>} */
338
+ /** @type {HookMap<SyncBailHook<[AssignmentExpression], boolean | void>>} */
303
339
  assign: new HookMap(() => new SyncBailHook(["expression"])),
304
- /** @type {HookMap<SyncBailHook<[import("estree").AssignmentExpression, string[]], boolean | void>>} */
340
+ /** @type {HookMap<SyncBailHook<[AssignmentExpression, string[]], boolean | void>>} */
305
341
  assignMemberChain: new HookMap(
306
342
  () => new SyncBailHook(["expression", "members"])
307
343
  ),
308
- /** @type {HookMap<SyncBailHook<[ExpressionNode], boolean | void>>} */
344
+ /** @type {HookMap<SyncBailHook<[Expression], boolean | void>>} */
309
345
  typeof: new HookMap(() => new SyncBailHook(["expression"])),
310
- /** @type {SyncBailHook<[ExpressionNode], boolean | void>} */
346
+ /** @type {SyncBailHook<[ImportExpression], boolean | void>} */
311
347
  importCall: new SyncBailHook(["expression"]),
312
- /** @type {SyncBailHook<[ExpressionNode], boolean | void>} */
348
+ /** @type {SyncBailHook<[Expression], boolean | void>} */
313
349
  topLevelAwait: new SyncBailHook(["expression"]),
314
- /** @type {HookMap<SyncBailHook<[ExpressionNode], boolean | void>>} */
350
+ /** @type {HookMap<SyncBailHook<[BaseCallExpression], boolean | void>>} */
315
351
  call: new HookMap(() => new SyncBailHook(["expression"])),
316
352
  /** Something like "a.b()" */
317
- /** @type {HookMap<SyncBailHook<[CallExpressionNode, string[], boolean[]], boolean | void>>} */
353
+ /** @type {HookMap<SyncBailHook<[CallExpression, string[], boolean[]], boolean | void>>} */
318
354
  callMemberChain: new HookMap(
319
355
  () => new SyncBailHook(["expression", "members", "membersOptionals"])
320
356
  ),
321
357
  /** Something like "a.b().c.d" */
322
- /** @type {HookMap<SyncBailHook<[ExpressionNode, string[], CallExpressionNode, string[]], boolean | void>>} */
358
+ /** @type {HookMap<SyncBailHook<[Expression, string[], CallExpression, string[]], boolean | void>>} */
323
359
  memberChainOfCallMemberChain: new HookMap(
324
360
  () =>
325
361
  new SyncBailHook([
@@ -330,7 +366,7 @@ class JavascriptParser extends Parser {
330
366
  ])
331
367
  ),
332
368
  /** Something like "a.b().c.d()"" */
333
- /** @type {HookMap<SyncBailHook<[ExpressionNode, string[], CallExpressionNode, string[]], boolean | void>>} */
369
+ /** @type {HookMap<SyncBailHook<[Expression, string[], CallExpression, string[]], boolean | void>>} */
334
370
  callMemberChainOfCallMemberChain: new HookMap(
335
371
  () =>
336
372
  new SyncBailHook([
@@ -340,29 +376,29 @@ class JavascriptParser extends Parser {
340
376
  "members"
341
377
  ])
342
378
  ),
343
- /** @type {SyncBailHook<[ChainExpressionNode], boolean | void>} */
379
+ /** @type {SyncBailHook<[ChainExpression], boolean | void>} */
344
380
  optionalChaining: new SyncBailHook(["optionalChaining"]),
345
- /** @type {HookMap<SyncBailHook<[NewExpressionNode], boolean | void>>} */
381
+ /** @type {HookMap<SyncBailHook<[NewExpression], boolean | void>>} */
346
382
  new: new HookMap(() => new SyncBailHook(["expression"])),
347
- /** @type {SyncBailHook<[BinaryExpressionNode], boolean | void>} */
383
+ /** @type {SyncBailHook<[BinaryExpression], boolean | void>} */
348
384
  binaryExpression: new SyncBailHook(["binaryExpression"]),
349
- /** @type {HookMap<SyncBailHook<[ExpressionNode], boolean | void>>} */
385
+ /** @type {HookMap<SyncBailHook<[Expression], boolean | void>>} */
350
386
  expression: new HookMap(() => new SyncBailHook(["expression"])),
351
- /** @type {HookMap<SyncBailHook<[ExpressionNode, string[], boolean[]], boolean | void>>} */
387
+ /** @type {HookMap<SyncBailHook<[Expression, string[], boolean[]], boolean | void>>} */
352
388
  expressionMemberChain: new HookMap(
353
389
  () => new SyncBailHook(["expression", "members", "membersOptionals"])
354
390
  ),
355
- /** @type {HookMap<SyncBailHook<[ExpressionNode, string[]], boolean | void>>} */
391
+ /** @type {HookMap<SyncBailHook<[Expression, string[]], boolean | void>>} */
356
392
  unhandledExpressionMemberChain: new HookMap(
357
393
  () => new SyncBailHook(["expression", "members"])
358
394
  ),
359
- /** @type {SyncBailHook<[ExpressionNode], boolean | void>} */
395
+ /** @type {SyncBailHook<[Expression], boolean | void>} */
360
396
  expressionConditionalOperator: new SyncBailHook(["expression"]),
361
- /** @type {SyncBailHook<[ExpressionNode], boolean | void>} */
397
+ /** @type {SyncBailHook<[Expression], boolean | void>} */
362
398
  expressionLogicalOperator: new SyncBailHook(["expression"]),
363
- /** @type {SyncBailHook<[ProgramNode, CommentNode[]], boolean | void>} */
399
+ /** @type {SyncBailHook<[Program, Comment[]], boolean | void>} */
364
400
  program: new SyncBailHook(["ast", "comments"]),
365
- /** @type {SyncBailHook<[ProgramNode, CommentNode[]], boolean | void>} */
401
+ /** @type {SyncBailHook<[Program, Comment[]], boolean | void>} */
366
402
  finish: new SyncBailHook(["ast", "comments"])
367
403
  });
368
404
  this.sourceType = sourceType;
@@ -372,10 +408,11 @@ class JavascriptParser extends Parser {
372
408
  this.state = undefined;
373
409
  this.comments = undefined;
374
410
  this.semicolons = undefined;
375
- /** @type {(StatementNode|ExpressionNode)[]} */
411
+ /** @type {(Statement | ModuleDeclaration | Expression)[]} */
376
412
  this.statementPath = undefined;
413
+ /** @type {Statement | ModuleDeclaration | Expression} */
377
414
  this.prevStatement = undefined;
378
- /** @type {WeakMap<ExpressionNode, Set<string>>} */
415
+ /** @type {WeakMap<Expression, Set<string>>} */
379
416
  this.destructuringAssignmentProperties = undefined;
380
417
  this.currentTagData = undefined;
381
418
  this._initializeEvaluating();
@@ -383,7 +420,7 @@ class JavascriptParser extends Parser {
383
420
 
384
421
  _initializeEvaluating() {
385
422
  this.hooks.evaluate.for("Literal").tap("JavascriptParser", _expr => {
386
- const expr = /** @type {LiteralNode} */ (_expr);
423
+ const expr = /** @type {Literal} */ (_expr);
387
424
 
388
425
  switch (typeof expr.value) {
389
426
  case "number":
@@ -413,7 +450,7 @@ class JavascriptParser extends Parser {
413
450
  }
414
451
  });
415
452
  this.hooks.evaluate.for("NewExpression").tap("JavascriptParser", _expr => {
416
- const expr = /** @type {NewExpressionNode} */ (_expr);
453
+ const expr = /** @type {NewExpression} */ (_expr);
417
454
  const callee = expr.callee;
418
455
  if (callee.type !== "Identifier") return;
419
456
  if (callee.name !== "RegExp") {
@@ -474,7 +511,7 @@ class JavascriptParser extends Parser {
474
511
  this.hooks.evaluate
475
512
  .for("LogicalExpression")
476
513
  .tap("JavascriptParser", _expr => {
477
- const expr = /** @type {LogicalExpressionNode} */ (_expr);
514
+ const expr = /** @type {LogicalExpression} */ (_expr);
478
515
 
479
516
  const left = this.evaluateExpression(expr.left);
480
517
  let returnRight = false;
@@ -533,13 +570,13 @@ class JavascriptParser extends Parser {
533
570
  * import("./" + foo + bar); // webpack will auto evaluate this into import("./foobar")
534
571
  * ```
535
572
  * @param {boolean | number | BigInt | string} value the value to convert to an expression
536
- * @param {BinaryExpressionNode | UnaryExpressionNode} expr the expression being evaluated
573
+ * @param {BinaryExpression | UnaryExpression} expr the expression being evaluated
537
574
  * @param {boolean} sideEffects whether the expression has side effects
538
575
  * @returns {BasicEvaluatedExpression} the evaluated expression
539
576
  * @example
540
577
  *
541
578
  * ```js
542
- * const binaryExpr = new BinaryExpressionNode("+",
579
+ * const binaryExpr = new BinaryExpression("+",
543
580
  * { type: "Literal", value: 2 },
544
581
  * { type: "Literal", value: 3 }
545
582
  * );
@@ -584,7 +621,7 @@ class JavascriptParser extends Parser {
584
621
  this.hooks.evaluate
585
622
  .for("BinaryExpression")
586
623
  .tap("JavascriptParser", _expr => {
587
- const expr = /** @type {BinaryExpressionNode} */ (_expr);
624
+ const expr = /** @type {BinaryExpression} */ (_expr);
588
625
 
589
626
  /**
590
627
  * Evaluates a binary expression if and only if it is a const operation (e.g. 1 + 2, "a" + "b", etc.).
@@ -935,7 +972,7 @@ class JavascriptParser extends Parser {
935
972
  this.hooks.evaluate
936
973
  .for("UnaryExpression")
937
974
  .tap("JavascriptParser", _expr => {
938
- const expr = /** @type {UnaryExpressionNode} */ (_expr);
975
+ const expr = /** @type {UnaryExpression} */ (_expr);
939
976
 
940
977
  /**
941
978
  * Evaluates a UnaryExpression if and only if it is a basic const operator (e.g. +a, -a, ~a).
@@ -1065,7 +1102,7 @@ class JavascriptParser extends Parser {
1065
1102
  .setRange(expr.range);
1066
1103
  });
1067
1104
  this.hooks.evaluate.for("Identifier").tap("JavascriptParser", expr => {
1068
- if (/** @type {IdentifierNode} */ (expr).name === "undefined") {
1105
+ if (/** @type {Identifier} */ (expr).name === "undefined") {
1069
1106
  return new BasicEvaluatedExpression()
1070
1107
  .setUndefined()
1071
1108
  .setRange(expr.range);
@@ -1073,16 +1110,16 @@ class JavascriptParser extends Parser {
1073
1110
  });
1074
1111
  /**
1075
1112
  * @param {string} exprType expression type name
1076
- * @param {function(ExpressionNode): GetInfoResult | undefined} getInfo get info
1113
+ * @param {function(Expression): GetInfoResult | undefined} getInfo get info
1077
1114
  * @returns {void}
1078
1115
  */
1079
1116
  const tapEvaluateWithVariableInfo = (exprType, getInfo) => {
1080
- /** @type {ExpressionNode | undefined} */
1117
+ /** @type {Expression | undefined} */
1081
1118
  let cachedExpression = undefined;
1082
1119
  /** @type {GetInfoResult | undefined} */
1083
1120
  let cachedInfo = undefined;
1084
1121
  this.hooks.evaluate.for(exprType).tap("JavascriptParser", expr => {
1085
- const expression = /** @type {MemberExpressionNode} */ (expr);
1122
+ const expression = /** @type {MemberExpression} */ (expr);
1086
1123
 
1087
1124
  const info = getInfo(expr);
1088
1125
  if (info !== undefined) {
@@ -1124,9 +1161,7 @@ class JavascriptParser extends Parser {
1124
1161
  });
1125
1162
  };
1126
1163
  tapEvaluateWithVariableInfo("Identifier", expr => {
1127
- const info = this.getVariableInfo(
1128
- /** @type {IdentifierNode} */ (expr).name
1129
- );
1164
+ const info = this.getVariableInfo(/** @type {Identifier} */ (expr).name);
1130
1165
  if (
1131
1166
  typeof info === "string" ||
1132
1167
  (info instanceof VariableInfo && typeof info.freeName === "string")
@@ -1154,7 +1189,7 @@ class JavascriptParser extends Parser {
1154
1189
  }
1155
1190
  });
1156
1191
  this.hooks.evaluate.for("MetaProperty").tap("JavascriptParser", expr => {
1157
- const metaProperty = /** @type {MetaPropertyNode} */ (expr);
1192
+ const metaProperty = /** @type {MetaProperty} */ (expr);
1158
1193
 
1159
1194
  return this.callHooksForName(
1160
1195
  this.hooks.evaluateIdentifier,
@@ -1164,13 +1199,13 @@ class JavascriptParser extends Parser {
1164
1199
  });
1165
1200
  tapEvaluateWithVariableInfo("MemberExpression", expr =>
1166
1201
  this.getMemberExpressionInfo(
1167
- /** @type {MemberExpressionNode} */ (expr),
1202
+ /** @type {MemberExpression} */ (expr),
1168
1203
  ALLOWED_MEMBER_TYPES_EXPRESSION
1169
1204
  )
1170
1205
  );
1171
1206
 
1172
1207
  this.hooks.evaluate.for("CallExpression").tap("JavascriptParser", _expr => {
1173
- const expr = /** @type {CallExpressionNode} */ (_expr);
1208
+ const expr = /** @type {CallExpression} */ (_expr);
1174
1209
  if (
1175
1210
  expr.callee.type === "MemberExpression" &&
1176
1211
  expr.callee.property.type ===
@@ -1178,7 +1213,7 @@ class JavascriptParser extends Parser {
1178
1213
  ) {
1179
1214
  // type Super also possible here
1180
1215
  const param = this.evaluateExpression(
1181
- /** @type {ExpressionNode} */ (expr.callee.object)
1216
+ /** @type {Expression} */ (expr.callee.object)
1182
1217
  );
1183
1218
  const property =
1184
1219
  expr.callee.property.type === "Literal"
@@ -1276,7 +1311,7 @@ class JavascriptParser extends Parser {
1276
1311
 
1277
1312
  /**
1278
1313
  * @param {"cooked" | "raw"} kind kind of values to get
1279
- * @param {TemplateLiteralNode} templateLiteralExpr TemplateLiteral expr
1314
+ * @param {TemplateLiteral} templateLiteralExpr TemplateLiteral expr
1280
1315
  * @returns {{quasis: BasicEvaluatedExpression[], parts: BasicEvaluatedExpression[]}} Simplified template
1281
1316
  */
1282
1317
  const getSimplifiedTemplateResult = (kind, templateLiteralExpr) => {
@@ -1327,7 +1362,7 @@ class JavascriptParser extends Parser {
1327
1362
  this.hooks.evaluate
1328
1363
  .for("TemplateLiteral")
1329
1364
  .tap("JavascriptParser", _node => {
1330
- const node = /** @type {TemplateLiteralNode} */ (_node);
1365
+ const node = /** @type {TemplateLiteral} */ (_node);
1331
1366
 
1332
1367
  const { quasis, parts } = getSimplifiedTemplateResult("cooked", node);
1333
1368
  if (parts.length === 1) {
@@ -1340,7 +1375,7 @@ class JavascriptParser extends Parser {
1340
1375
  this.hooks.evaluate
1341
1376
  .for("TaggedTemplateExpression")
1342
1377
  .tap("JavascriptParser", _node => {
1343
- const node = /** @type {TaggedTemplateExpressionNode} */ (_node);
1378
+ const node = /** @type {TaggedTemplateExpression} */ (_node);
1344
1379
  const tag = this.evaluateExpression(node.tag);
1345
1380
 
1346
1381
  if (tag.isIdentifier() && tag.identifier === "String.raw") {
@@ -1380,7 +1415,7 @@ class JavascriptParser extends Parser {
1380
1415
  : "" + argExpr.number;
1381
1416
 
1382
1417
  const newString = value + (stringSuffix ? stringSuffix.string : "");
1383
- const newRange = /** @type {[number, number]} */ ([
1418
+ const newRange = /** @type {Range} */ ([
1384
1419
  argExpr.range[0],
1385
1420
  (stringSuffix || argExpr).range[1]
1386
1421
  ]);
@@ -1445,7 +1480,7 @@ class JavascriptParser extends Parser {
1445
1480
  this.hooks.evaluate
1446
1481
  .for("ConditionalExpression")
1447
1482
  .tap("JavascriptParser", _expr => {
1448
- const expr = /** @type {ConditionalExpressionNode} */ (_expr);
1483
+ const expr = /** @type {ConditionalExpression} */ (_expr);
1449
1484
 
1450
1485
  const condition = this.evaluateExpression(expr.test);
1451
1486
  const conditionValue = condition.asBool();
@@ -1476,7 +1511,7 @@ class JavascriptParser extends Parser {
1476
1511
  this.hooks.evaluate
1477
1512
  .for("ArrayExpression")
1478
1513
  .tap("JavascriptParser", _expr => {
1479
- const expr = /** @type {ArrayExpressionNode} */ (_expr);
1514
+ const expr = /** @type {ArrayExpression} */ (_expr);
1480
1515
 
1481
1516
  const items = expr.elements.map(element => {
1482
1517
  return (
@@ -1493,10 +1528,10 @@ class JavascriptParser extends Parser {
1493
1528
  this.hooks.evaluate
1494
1529
  .for("ChainExpression")
1495
1530
  .tap("JavascriptParser", _expr => {
1496
- const expr = /** @type {ChainExpressionNode} */ (_expr);
1497
- /** @type {ExpressionNode[]} */
1531
+ const expr = /** @type {ChainExpression} */ (_expr);
1532
+ /** @type {Expression[]} */
1498
1533
  const optionalExpressionsStack = [];
1499
- /** @type {ExpressionNode|SuperNode} */
1534
+ /** @type {Expression|Super} */
1500
1535
  let next = expr.expression;
1501
1536
 
1502
1537
  while (
@@ -1507,7 +1542,7 @@ class JavascriptParser extends Parser {
1507
1542
  if (next.optional) {
1508
1543
  // SuperNode can not be optional
1509
1544
  optionalExpressionsStack.push(
1510
- /** @type {ExpressionNode} */ (next.object)
1545
+ /** @type {Expression} */ (next.object)
1511
1546
  );
1512
1547
  }
1513
1548
  next = next.object;
@@ -1515,7 +1550,7 @@ class JavascriptParser extends Parser {
1515
1550
  if (next.optional) {
1516
1551
  // SuperNode can not be optional
1517
1552
  optionalExpressionsStack.push(
1518
- /** @type {ExpressionNode} */ (next.callee)
1553
+ /** @type {Expression} */ (next.callee)
1519
1554
  );
1520
1555
  }
1521
1556
  next = next.callee;
@@ -1535,7 +1570,7 @@ class JavascriptParser extends Parser {
1535
1570
  }
1536
1571
 
1537
1572
  /**
1538
- * @param {ExpressionNode} node node
1573
+ * @param {Expression} node node
1539
1574
  * @returns {Set<string>|undefined} destructured identifiers
1540
1575
  */
1541
1576
  destructuringAssignmentPropertiesFor(node) {
@@ -1543,6 +1578,10 @@ class JavascriptParser extends Parser {
1543
1578
  return this.destructuringAssignmentProperties.get(node);
1544
1579
  }
1545
1580
 
1581
+ /**
1582
+ * @param {Expression} expr expression
1583
+ * @returns {string | VariableInfoInterface | undefined} identifier
1584
+ */
1546
1585
  getRenameIdentifier(expr) {
1547
1586
  const result = this.evaluateExpression(expr);
1548
1587
  if (result.isIdentifier()) {
@@ -1551,7 +1590,7 @@ class JavascriptParser extends Parser {
1551
1590
  }
1552
1591
 
1553
1592
  /**
1554
- * @param {ClassExpressionNode | ClassDeclarationNode} classy a class node
1593
+ * @param {ClassExpression | ClassDeclaration} classy a class node
1555
1594
  * @returns {void}
1556
1595
  */
1557
1596
  walkClass(classy) {
@@ -1561,36 +1600,47 @@ class JavascriptParser extends Parser {
1561
1600
  }
1562
1601
  }
1563
1602
  if (classy.body && classy.body.type === "ClassBody") {
1564
- for (const classElement of /** @type {TODO} */ (classy.body.body)) {
1565
- if (!this.hooks.classBodyElement.call(classElement, classy)) {
1566
- if (classElement.computed && classElement.key) {
1567
- this.walkExpression(classElement.key);
1568
- }
1569
- if (classElement.value) {
1570
- if (
1571
- !this.hooks.classBodyValue.call(
1572
- classElement.value,
1573
- classElement,
1574
- classy
1575
- )
1576
- ) {
1603
+ const scopeParams = [];
1604
+ // Add class name in scope for recursive calls
1605
+ if (classy.id) {
1606
+ scopeParams.push(classy.id);
1607
+ }
1608
+ this.inClassScope(true, scopeParams, () => {
1609
+ for (const classElement of /** @type {TODO} */ (classy.body.body)) {
1610
+ if (!this.hooks.classBodyElement.call(classElement, classy)) {
1611
+ if (classElement.computed && classElement.key) {
1612
+ this.walkExpression(classElement.key);
1613
+ }
1614
+ if (classElement.value) {
1615
+ if (
1616
+ !this.hooks.classBodyValue.call(
1617
+ classElement.value,
1618
+ classElement,
1619
+ classy
1620
+ )
1621
+ ) {
1622
+ const wasTopLevel = this.scope.topLevelScope;
1623
+ this.scope.topLevelScope = false;
1624
+ this.walkExpression(classElement.value);
1625
+ this.scope.topLevelScope = wasTopLevel;
1626
+ }
1627
+ } else if (classElement.type === "StaticBlock") {
1577
1628
  const wasTopLevel = this.scope.topLevelScope;
1578
1629
  this.scope.topLevelScope = false;
1579
- this.walkExpression(classElement.value);
1630
+ this.walkBlockStatement(classElement);
1580
1631
  this.scope.topLevelScope = wasTopLevel;
1581
1632
  }
1582
- } else if (classElement.type === "StaticBlock") {
1583
- const wasTopLevel = this.scope.topLevelScope;
1584
- this.scope.topLevelScope = false;
1585
- this.walkBlockStatement(classElement);
1586
- this.scope.topLevelScope = wasTopLevel;
1587
1633
  }
1588
1634
  }
1589
- }
1635
+ });
1590
1636
  }
1591
1637
  }
1592
1638
 
1593
- // Pre walking iterates the scope for variable declarations
1639
+ /**
1640
+ * Pre walking iterates the scope for variable declarations
1641
+ *
1642
+ * @param {(Statement | ModuleDeclaration)[]} statements statements
1643
+ */
1594
1644
  preWalkStatements(statements) {
1595
1645
  for (let index = 0, len = statements.length; index < len; index++) {
1596
1646
  const statement = statements[index];
@@ -1598,7 +1648,11 @@ class JavascriptParser extends Parser {
1598
1648
  }
1599
1649
  }
1600
1650
 
1601
- // Block pre walking iterates the scope for block variable declarations
1651
+ /**
1652
+ * Block pre walking iterates the scope for block variable declarations
1653
+ *
1654
+ * @param {(Statement | ModuleDeclaration)[]} statements statements
1655
+ */
1602
1656
  blockPreWalkStatements(statements) {
1603
1657
  for (let index = 0, len = statements.length; index < len; index++) {
1604
1658
  const statement = statements[index];
@@ -1606,7 +1660,11 @@ class JavascriptParser extends Parser {
1606
1660
  }
1607
1661
  }
1608
1662
 
1609
- // Walking iterates the statements and expressions and processes them
1663
+ /**
1664
+ * Walking iterates the statements and expressions and processes them
1665
+ *
1666
+ * @param {(Statement | ModuleDeclaration)[]} statements statements
1667
+ */
1610
1668
  walkStatements(statements) {
1611
1669
  for (let index = 0, len = statements.length; index < len; index++) {
1612
1670
  const statement = statements[index];
@@ -1614,6 +1672,11 @@ class JavascriptParser extends Parser {
1614
1672
  }
1615
1673
  }
1616
1674
 
1675
+ /**
1676
+ * Walking iterates the statements and expressions and processes them
1677
+ *
1678
+ * @param {Statement | ModuleDeclaration} statement statement
1679
+ */
1617
1680
  preWalkStatement(statement) {
1618
1681
  this.statementPath.push(statement);
1619
1682
  if (this.hooks.preStatement.call(statement)) {
@@ -1664,6 +1727,9 @@ class JavascriptParser extends Parser {
1664
1727
  this.prevStatement = this.statementPath.pop();
1665
1728
  }
1666
1729
 
1730
+ /**
1731
+ * @param {Statement | ModuleDeclaration} statement statement
1732
+ */
1667
1733
  blockPreWalkStatement(statement) {
1668
1734
  this.statementPath.push(statement);
1669
1735
  if (this.hooks.blockPreStatement.call(statement)) {
@@ -1695,6 +1761,9 @@ class JavascriptParser extends Parser {
1695
1761
  this.prevStatement = this.statementPath.pop();
1696
1762
  }
1697
1763
 
1764
+ /**
1765
+ * @param {Statement | ModuleDeclaration} statement statement
1766
+ */
1698
1767
  walkStatement(statement) {
1699
1768
  this.statementPath.push(statement);
1700
1769
  if (this.hooks.statement.call(statement) !== undefined) {
@@ -1767,8 +1836,8 @@ class JavascriptParser extends Parser {
1767
1836
  * Walks a statements that is nested within a parent statement
1768
1837
  * and can potentially be a non-block statement.
1769
1838
  * This enforces the nested statement to never be in ASI position.
1770
- * @param {StatementNode} statement the nested statement
1771
- * @returns {void}
1839
+ *
1840
+ * @param {Statement} statement the nested statement
1772
1841
  */
1773
1842
  walkNestedStatement(statement) {
1774
1843
  this.prevStatement = undefined;
@@ -1776,10 +1845,16 @@ class JavascriptParser extends Parser {
1776
1845
  }
1777
1846
 
1778
1847
  // Real Statements
1848
+ /**
1849
+ * @param {BlockStatement} statement block statement
1850
+ */
1779
1851
  preWalkBlockStatement(statement) {
1780
1852
  this.preWalkStatements(statement.body);
1781
1853
  }
1782
1854
 
1855
+ /**
1856
+ * @param {BlockStatement} statement block statement
1857
+ */
1783
1858
  walkBlockStatement(statement) {
1784
1859
  this.inBlockScope(() => {
1785
1860
  const body = statement.body;
@@ -1790,10 +1865,16 @@ class JavascriptParser extends Parser {
1790
1865
  });
1791
1866
  }
1792
1867
 
1868
+ /**
1869
+ * @param {ExpressionStatement} statement expression statement
1870
+ */
1793
1871
  walkExpressionStatement(statement) {
1794
1872
  this.walkExpression(statement.expression);
1795
1873
  }
1796
1874
 
1875
+ /**
1876
+ * @param {IfStatement} statement if statement
1877
+ */
1797
1878
  preWalkIfStatement(statement) {
1798
1879
  this.preWalkStatement(statement.consequent);
1799
1880
  if (statement.alternate) {
@@ -1801,6 +1882,9 @@ class JavascriptParser extends Parser {
1801
1882
  }
1802
1883
  }
1803
1884
 
1885
+ /**
1886
+ * @param {IfStatement} statement if statement
1887
+ */
1804
1888
  walkIfStatement(statement) {
1805
1889
  const result = this.hooks.statementIf.call(statement);
1806
1890
  if (result === undefined) {
@@ -1818,10 +1902,16 @@ class JavascriptParser extends Parser {
1818
1902
  }
1819
1903
  }
1820
1904
 
1905
+ /**
1906
+ * @param {LabeledStatement} statement with statement
1907
+ */
1821
1908
  preWalkLabeledStatement(statement) {
1822
1909
  this.preWalkStatement(statement.body);
1823
1910
  }
1824
1911
 
1912
+ /**
1913
+ * @param {LabeledStatement} statement with statement
1914
+ */
1825
1915
  walkLabeledStatement(statement) {
1826
1916
  const hook = this.hooks.label.get(statement.label.name);
1827
1917
  if (hook !== undefined) {
@@ -1831,42 +1921,69 @@ class JavascriptParser extends Parser {
1831
1921
  this.walkNestedStatement(statement.body);
1832
1922
  }
1833
1923
 
1924
+ /**
1925
+ * @param {WithStatement} statement with statement
1926
+ */
1834
1927
  preWalkWithStatement(statement) {
1835
1928
  this.preWalkStatement(statement.body);
1836
1929
  }
1837
1930
 
1931
+ /**
1932
+ * @param {WithStatement} statement with statement
1933
+ */
1838
1934
  walkWithStatement(statement) {
1839
1935
  this.walkExpression(statement.object);
1840
1936
  this.walkNestedStatement(statement.body);
1841
1937
  }
1842
1938
 
1939
+ /**
1940
+ * @param {SwitchStatement} statement switch statement
1941
+ */
1843
1942
  preWalkSwitchStatement(statement) {
1844
1943
  this.preWalkSwitchCases(statement.cases);
1845
1944
  }
1846
1945
 
1946
+ /**
1947
+ * @param {SwitchStatement} statement switch statement
1948
+ */
1847
1949
  walkSwitchStatement(statement) {
1848
1950
  this.walkExpression(statement.discriminant);
1849
1951
  this.walkSwitchCases(statement.cases);
1850
1952
  }
1851
1953
 
1954
+ /**
1955
+ * @param {ReturnStatement | ThrowStatement} statement return or throw statement
1956
+ */
1852
1957
  walkTerminatingStatement(statement) {
1853
1958
  if (statement.argument) this.walkExpression(statement.argument);
1854
1959
  }
1855
1960
 
1961
+ /**
1962
+ * @param {ReturnStatement} statement return statement
1963
+ */
1856
1964
  walkReturnStatement(statement) {
1857
1965
  this.walkTerminatingStatement(statement);
1858
1966
  }
1859
1967
 
1968
+ /**
1969
+ * @param {ThrowStatement} statement return statement
1970
+ */
1860
1971
  walkThrowStatement(statement) {
1861
1972
  this.walkTerminatingStatement(statement);
1862
1973
  }
1863
1974
 
1975
+ /**
1976
+ * @param {TryStatement} statement try statement
1977
+ */
1864
1978
  preWalkTryStatement(statement) {
1865
1979
  this.preWalkStatement(statement.block);
1866
1980
  if (statement.handler) this.preWalkCatchClause(statement.handler);
1867
1981
  if (statement.finalizer) this.preWalkStatement(statement.finalizer);
1868
1982
  }
1869
1983
 
1984
+ /**
1985
+ * @param {TryStatement} statement try statement
1986
+ */
1870
1987
  walkTryStatement(statement) {
1871
1988
  if (this.scope.inTry) {
1872
1989
  this.walkStatement(statement.block);
@@ -1879,24 +1996,39 @@ class JavascriptParser extends Parser {
1879
1996
  if (statement.finalizer) this.walkStatement(statement.finalizer);
1880
1997
  }
1881
1998
 
1999
+ /**
2000
+ * @param {WhileStatement} statement while statement
2001
+ */
1882
2002
  preWalkWhileStatement(statement) {
1883
2003
  this.preWalkStatement(statement.body);
1884
2004
  }
1885
2005
 
2006
+ /**
2007
+ * @param {WhileStatement} statement while statement
2008
+ */
1886
2009
  walkWhileStatement(statement) {
1887
2010
  this.walkExpression(statement.test);
1888
2011
  this.walkNestedStatement(statement.body);
1889
2012
  }
1890
2013
 
2014
+ /**
2015
+ * @param {DoWhileStatement} statement do while statement
2016
+ */
1891
2017
  preWalkDoWhileStatement(statement) {
1892
2018
  this.preWalkStatement(statement.body);
1893
2019
  }
1894
2020
 
2021
+ /**
2022
+ * @param {DoWhileStatement} statement do while statement
2023
+ */
1895
2024
  walkDoWhileStatement(statement) {
1896
2025
  this.walkNestedStatement(statement.body);
1897
2026
  this.walkExpression(statement.test);
1898
2027
  }
1899
2028
 
2029
+ /**
2030
+ * @param {ForStatement} statement for statement
2031
+ */
1900
2032
  preWalkForStatement(statement) {
1901
2033
  if (statement.init) {
1902
2034
  if (statement.init.type === "VariableDeclaration") {
@@ -1906,6 +2038,9 @@ class JavascriptParser extends Parser {
1906
2038
  this.preWalkStatement(statement.body);
1907
2039
  }
1908
2040
 
2041
+ /**
2042
+ * @param {ForStatement} statement for statement
2043
+ */
1909
2044
  walkForStatement(statement) {
1910
2045
  this.inBlockScope(() => {
1911
2046
  if (statement.init) {
@@ -1936,6 +2071,9 @@ class JavascriptParser extends Parser {
1936
2071
  });
1937
2072
  }
1938
2073
 
2074
+ /**
2075
+ * @param {ForInStatement} statement for statement
2076
+ */
1939
2077
  preWalkForInStatement(statement) {
1940
2078
  if (statement.left.type === "VariableDeclaration") {
1941
2079
  this.preWalkVariableDeclaration(statement.left);
@@ -1943,6 +2081,9 @@ class JavascriptParser extends Parser {
1943
2081
  this.preWalkStatement(statement.body);
1944
2082
  }
1945
2083
 
2084
+ /**
2085
+ * @param {ForInStatement} statement for statement
2086
+ */
1946
2087
  walkForInStatement(statement) {
1947
2088
  this.inBlockScope(() => {
1948
2089
  if (statement.left.type === "VariableDeclaration") {
@@ -1975,6 +2116,9 @@ class JavascriptParser extends Parser {
1975
2116
  this.preWalkStatement(statement.body);
1976
2117
  }
1977
2118
 
2119
+ /**
2120
+ * @param {ForOfStatement} statement for statement
2121
+ */
1978
2122
  walkForOfStatement(statement) {
1979
2123
  this.inBlockScope(() => {
1980
2124
  if (statement.left.type === "VariableDeclaration") {
@@ -1997,13 +2141,18 @@ class JavascriptParser extends Parser {
1997
2141
  });
1998
2142
  }
1999
2143
 
2000
- // Declarations
2144
+ /**
2145
+ * @param {FunctionDeclaration} statement function declaration
2146
+ */
2001
2147
  preWalkFunctionDeclaration(statement) {
2002
2148
  if (statement.id) {
2003
2149
  this.defineVariable(statement.id.name);
2004
2150
  }
2005
2151
  }
2006
2152
 
2153
+ /**
2154
+ * @param {FunctionDeclaration} statement function declaration
2155
+ */
2007
2156
  walkFunctionDeclaration(statement) {
2008
2157
  const wasTopLevel = this.scope.topLevelScope;
2009
2158
  this.scope.topLevelScope = false;
@@ -2024,6 +2173,9 @@ class JavascriptParser extends Parser {
2024
2173
  this.scope.topLevelScope = wasTopLevel;
2025
2174
  }
2026
2175
 
2176
+ /**
2177
+ * @param {ExpressionStatement} statement expression statement
2178
+ */
2027
2179
  blockPreWalkExpressionStatement(statement) {
2028
2180
  const expression = statement.expression;
2029
2181
  switch (expression.type) {
@@ -2032,6 +2184,9 @@ class JavascriptParser extends Parser {
2032
2184
  }
2033
2185
  }
2034
2186
 
2187
+ /**
2188
+ * @param {AssignmentExpression} expression assignment expression
2189
+ */
2035
2190
  preWalkAssignmentExpression(expression) {
2036
2191
  if (
2037
2192
  expression.left.type !== "ObjectPattern" ||
@@ -2172,6 +2327,9 @@ class JavascriptParser extends Parser {
2172
2327
  }
2173
2328
  }
2174
2329
 
2330
+ /**
2331
+ * @param {ExportNamedDeclaration} statement the statement
2332
+ */
2175
2333
  walkExportNamedDeclaration(statement) {
2176
2334
  if (statement.declaration) {
2177
2335
  this.walkStatement(statement.declaration);
@@ -2239,11 +2397,17 @@ class JavascriptParser extends Parser {
2239
2397
  this.hooks.exportImportSpecifier.call(statement, source, null, name, 0);
2240
2398
  }
2241
2399
 
2400
+ /**
2401
+ * @param {VariableDeclaration} statement variable declaration
2402
+ */
2242
2403
  preWalkVariableDeclaration(statement) {
2243
2404
  if (statement.kind !== "var") return;
2244
2405
  this._preWalkVariableDeclaration(statement, this.hooks.varDeclarationVar);
2245
2406
  }
2246
2407
 
2408
+ /**
2409
+ * @param {VariableDeclaration} statement variable declaration
2410
+ */
2247
2411
  blockPreWalkVariableDeclaration(statement) {
2248
2412
  if (statement.kind === "var") return;
2249
2413
  const hookMap =
@@ -2253,6 +2417,10 @@ class JavascriptParser extends Parser {
2253
2417
  this._preWalkVariableDeclaration(statement, hookMap);
2254
2418
  }
2255
2419
 
2420
+ /**
2421
+ * @param {VariableDeclaration} statement variable declaration
2422
+ * @param {TODO} hookMap map of hooks
2423
+ */
2256
2424
  _preWalkVariableDeclaration(statement, hookMap) {
2257
2425
  for (const declarator of statement.declarations) {
2258
2426
  switch (declarator.type) {
@@ -2299,6 +2467,9 @@ class JavascriptParser extends Parser {
2299
2467
  return ids;
2300
2468
  }
2301
2469
 
2470
+ /**
2471
+ * @param {VariableDeclarator} declarator variable declarator
2472
+ */
2302
2473
  preWalkVariableDeclarator(declarator) {
2303
2474
  if (
2304
2475
  !declarator.init ||
@@ -2321,6 +2492,9 @@ class JavascriptParser extends Parser {
2321
2492
  }
2322
2493
  }
2323
2494
 
2495
+ /**
2496
+ * @param {VariableDeclaration} statement variable declaration
2497
+ */
2324
2498
  walkVariableDeclaration(statement) {
2325
2499
  for (const declarator of statement.declarations) {
2326
2500
  switch (declarator.type) {
@@ -2348,16 +2522,25 @@ class JavascriptParser extends Parser {
2348
2522
  }
2349
2523
  }
2350
2524
 
2525
+ /**
2526
+ * @param {ClassDeclaration} statement class declaration
2527
+ */
2351
2528
  blockPreWalkClassDeclaration(statement) {
2352
2529
  if (statement.id) {
2353
2530
  this.defineVariable(statement.id.name);
2354
2531
  }
2355
2532
  }
2356
2533
 
2534
+ /**
2535
+ * @param {ClassDeclaration} statement class declaration
2536
+ */
2357
2537
  walkClassDeclaration(statement) {
2358
2538
  this.walkClass(statement);
2359
2539
  }
2360
2540
 
2541
+ /**
2542
+ * @param {SwitchCase[]} switchCases switch statement
2543
+ */
2361
2544
  preWalkSwitchCases(switchCases) {
2362
2545
  for (let index = 0, len = switchCases.length; index < len; index++) {
2363
2546
  const switchCase = switchCases[index];
@@ -2365,6 +2548,9 @@ class JavascriptParser extends Parser {
2365
2548
  }
2366
2549
  }
2367
2550
 
2551
+ /**
2552
+ * @param {SwitchCase[]} switchCases switch statement
2553
+ */
2368
2554
  walkSwitchCases(switchCases) {
2369
2555
  this.inBlockScope(() => {
2370
2556
  const len = switchCases.length;
@@ -2400,10 +2586,16 @@ class JavascriptParser extends Parser {
2400
2586
  });
2401
2587
  }
2402
2588
 
2589
+ /**
2590
+ * @param {CatchClause} catchClause catch clause
2591
+ */
2403
2592
  preWalkCatchClause(catchClause) {
2404
2593
  this.preWalkStatement(catchClause.body);
2405
2594
  }
2406
2595
 
2596
+ /**
2597
+ * @param {CatchClause} catchClause catch clause
2598
+ */
2407
2599
  walkCatchClause(catchClause) {
2408
2600
  this.inBlockScope(() => {
2409
2601
  // Error binding is optional in catch clause since ECMAScript 2019
@@ -2420,6 +2612,9 @@ class JavascriptParser extends Parser {
2420
2612
  });
2421
2613
  }
2422
2614
 
2615
+ /**
2616
+ * @param {Pattern} pattern pattern
2617
+ */
2423
2618
  walkPattern(pattern) {
2424
2619
  switch (pattern.type) {
2425
2620
  case "ArrayPattern":
@@ -2440,6 +2635,9 @@ class JavascriptParser extends Parser {
2440
2635
  }
2441
2636
  }
2442
2637
 
2638
+ /**
2639
+ * @param {AssignmentPattern} pattern assignment pattern
2640
+ */
2443
2641
  walkAssignmentPattern(pattern) {
2444
2642
  this.walkExpression(pattern.right);
2445
2643
  this.walkPattern(pattern.left);
@@ -2455,6 +2653,9 @@ class JavascriptParser extends Parser {
2455
2653
  }
2456
2654
  }
2457
2655
 
2656
+ /**
2657
+ * @param {ArrayPattern} pattern array pattern
2658
+ */
2458
2659
  walkArrayPattern(pattern) {
2459
2660
  for (let i = 0, len = pattern.elements.length; i < len; i++) {
2460
2661
  const element = pattern.elements[i];
@@ -2462,10 +2663,16 @@ class JavascriptParser extends Parser {
2462
2663
  }
2463
2664
  }
2464
2665
 
2666
+ /**
2667
+ * @param {RestElement} pattern rest element
2668
+ */
2465
2669
  walkRestElement(pattern) {
2466
2670
  this.walkPattern(pattern.argument);
2467
2671
  }
2468
2672
 
2673
+ /**
2674
+ * @param {(Expression | SpreadElement | null)[]} expressions expressions
2675
+ */
2469
2676
  walkExpressions(expressions) {
2470
2677
  for (const expression of expressions) {
2471
2678
  if (expression) {
@@ -2554,24 +2761,36 @@ class JavascriptParser extends Parser {
2554
2761
  }
2555
2762
  }
2556
2763
 
2764
+ /**
2765
+ * @param {AwaitExpression} expression await expression
2766
+ */
2557
2767
  walkAwaitExpression(expression) {
2558
2768
  if (this.scope.topLevelScope === true)
2559
2769
  this.hooks.topLevelAwait.call(expression);
2560
2770
  this.walkExpression(expression.argument);
2561
2771
  }
2562
2772
 
2773
+ /**
2774
+ * @param {ArrayExpression} expression array expression
2775
+ */
2563
2776
  walkArrayExpression(expression) {
2564
2777
  if (expression.elements) {
2565
2778
  this.walkExpressions(expression.elements);
2566
2779
  }
2567
2780
  }
2568
2781
 
2782
+ /**
2783
+ * @param {SpreadElement} expression spread element
2784
+ */
2569
2785
  walkSpreadElement(expression) {
2570
2786
  if (expression.argument) {
2571
2787
  this.walkExpression(expression.argument);
2572
2788
  }
2573
2789
  }
2574
2790
 
2791
+ /**
2792
+ * @param {ObjectExpression} expression object expression
2793
+ */
2575
2794
  walkObjectExpression(expression) {
2576
2795
  for (
2577
2796
  let propIndex = 0, len = expression.properties.length;
@@ -2583,6 +2802,9 @@ class JavascriptParser extends Parser {
2583
2802
  }
2584
2803
  }
2585
2804
 
2805
+ /**
2806
+ * @param {Property | SpreadElement} prop property or spread element
2807
+ */
2586
2808
  walkProperty(prop) {
2587
2809
  if (prop.type === "SpreadElement") {
2588
2810
  this.walkExpression(prop.argument);
@@ -2600,6 +2822,9 @@ class JavascriptParser extends Parser {
2600
2822
  }
2601
2823
  }
2602
2824
 
2825
+ /**
2826
+ * @param {FunctionExpression} expression arrow function expression
2827
+ */
2603
2828
  walkFunctionExpression(expression) {
2604
2829
  const wasTopLevel = this.scope.topLevelScope;
2605
2830
  this.scope.topLevelScope = false;
@@ -2607,7 +2832,7 @@ class JavascriptParser extends Parser {
2607
2832
 
2608
2833
  // Add function name in scope for recursive calls
2609
2834
  if (expression.id) {
2610
- scopeParams.push(expression.id.name);
2835
+ scopeParams.push(expression.id);
2611
2836
  }
2612
2837
 
2613
2838
  this.inFunctionScope(true, scopeParams, () => {
@@ -2627,6 +2852,9 @@ class JavascriptParser extends Parser {
2627
2852
  this.scope.topLevelScope = wasTopLevel;
2628
2853
  }
2629
2854
 
2855
+ /**
2856
+ * @param {ArrowFunctionExpression} expression arrow function expression
2857
+ */
2630
2858
  walkArrowFunctionExpression(expression) {
2631
2859
  const wasTopLevel = this.scope.topLevelScope;
2632
2860
  this.scope.topLevelScope = wasTopLevel ? "arrow" : false;
@@ -2648,7 +2876,7 @@ class JavascriptParser extends Parser {
2648
2876
  }
2649
2877
 
2650
2878
  /**
2651
- * @param {SequenceExpressionNode} expression the sequence
2879
+ * @param {SequenceExpression} expression the sequence
2652
2880
  */
2653
2881
  walkSequenceExpression(expression) {
2654
2882
  if (!expression.expressions) return;
@@ -2672,10 +2900,16 @@ class JavascriptParser extends Parser {
2672
2900
  }
2673
2901
  }
2674
2902
 
2903
+ /**
2904
+ * @param {UpdateExpression} expression the update expression
2905
+ */
2675
2906
  walkUpdateExpression(expression) {
2676
2907
  this.walkExpression(expression.argument);
2677
2908
  }
2678
2909
 
2910
+ /**
2911
+ * @param {UnaryExpression} expression the unary expression
2912
+ */
2679
2913
  walkUnaryExpression(expression) {
2680
2914
  if (expression.operator === "typeof") {
2681
2915
  const result = this.callHooksForExpression(
@@ -2696,17 +2930,26 @@ class JavascriptParser extends Parser {
2696
2930
  this.walkExpression(expression.argument);
2697
2931
  }
2698
2932
 
2933
+ /**
2934
+ * @param {LogicalExpression | BinaryExpression} expression the expression
2935
+ */
2699
2936
  walkLeftRightExpression(expression) {
2700
2937
  this.walkExpression(expression.left);
2701
2938
  this.walkExpression(expression.right);
2702
2939
  }
2703
2940
 
2941
+ /**
2942
+ * @param {BinaryExpression} expression the binary expression
2943
+ */
2704
2944
  walkBinaryExpression(expression) {
2705
2945
  if (this.hooks.binaryExpression.call(expression) === undefined) {
2706
2946
  this.walkLeftRightExpression(expression);
2707
2947
  }
2708
2948
  }
2709
2949
 
2950
+ /**
2951
+ * @param {LogicalExpression} expression the logical expression
2952
+ */
2710
2953
  walkLogicalExpression(expression) {
2711
2954
  const result = this.hooks.expressionLogicalOperator.call(expression);
2712
2955
  if (result === undefined) {
@@ -2718,6 +2961,9 @@ class JavascriptParser extends Parser {
2718
2961
  }
2719
2962
  }
2720
2963
 
2964
+ /**
2965
+ * @param {AssignmentExpression} expression assignment expression
2966
+ */
2721
2967
  walkAssignmentExpression(expression) {
2722
2968
  if (expression.left.type === "Identifier") {
2723
2969
  const renameIdentifier = this.getRenameIdentifier(expression.right);
@@ -2788,6 +3034,9 @@ class JavascriptParser extends Parser {
2788
3034
  }
2789
3035
  }
2790
3036
 
3037
+ /**
3038
+ * @param {ConditionalExpression} expression conditional expression
3039
+ */
2791
3040
  walkConditionalExpression(expression) {
2792
3041
  const result = this.hooks.expressionConditionalOperator.call(expression);
2793
3042
  if (result === undefined) {
@@ -2805,6 +3054,9 @@ class JavascriptParser extends Parser {
2805
3054
  }
2806
3055
  }
2807
3056
 
3057
+ /**
3058
+ * @param {NewExpression} expression new expression
3059
+ */
2808
3060
  walkNewExpression(expression) {
2809
3061
  const result = this.callHooksForExpression(
2810
3062
  this.hooks.new,
@@ -2818,18 +3070,27 @@ class JavascriptParser extends Parser {
2818
3070
  }
2819
3071
  }
2820
3072
 
3073
+ /**
3074
+ * @param {YieldExpression} expression yield expression
3075
+ */
2821
3076
  walkYieldExpression(expression) {
2822
3077
  if (expression.argument) {
2823
3078
  this.walkExpression(expression.argument);
2824
3079
  }
2825
3080
  }
2826
3081
 
3082
+ /**
3083
+ * @param {TemplateLiteral} expression template literal
3084
+ */
2827
3085
  walkTemplateLiteral(expression) {
2828
3086
  if (expression.expressions) {
2829
3087
  this.walkExpressions(expression.expressions);
2830
3088
  }
2831
3089
  }
2832
3090
 
3091
+ /**
3092
+ * @param {TaggedTemplateExpression} expression tagged template expression
3093
+ */
2833
3094
  walkTaggedTemplateExpression(expression) {
2834
3095
  if (expression.tag) {
2835
3096
  this.walkExpression(expression.tag);
@@ -2839,12 +3100,15 @@ class JavascriptParser extends Parser {
2839
3100
  }
2840
3101
  }
2841
3102
 
3103
+ /**
3104
+ * @param {ClassExpression} expression the class expression
3105
+ */
2842
3106
  walkClassExpression(expression) {
2843
3107
  this.walkClass(expression);
2844
3108
  }
2845
3109
 
2846
3110
  /**
2847
- * @param {ChainExpressionNode} expression expression
3111
+ * @param {ChainExpression} expression expression
2848
3112
  */
2849
3113
  walkChainExpression(expression) {
2850
3114
  const result = this.hooks.optionalChaining.call(expression);
@@ -2922,6 +3186,9 @@ class JavascriptParser extends Parser {
2922
3186
  this.scope.topLevelScope = wasTopLevel;
2923
3187
  }
2924
3188
 
3189
+ /**
3190
+ * @param {ImportExpression} expression import expression
3191
+ */
2925
3192
  walkImportExpression(expression) {
2926
3193
  let result = this.hooks.importCall.call(expression);
2927
3194
  if (result === true) return;
@@ -3006,6 +3273,9 @@ class JavascriptParser extends Parser {
3006
3273
  }
3007
3274
  }
3008
3275
 
3276
+ /**
3277
+ * @param {MemberExpression} expression member expression
3278
+ */
3009
3279
  walkMemberExpression(expression) {
3010
3280
  const exprInfo = this.getMemberExpressionInfo(
3011
3281
  expression,
@@ -3099,16 +3369,22 @@ class JavascriptParser extends Parser {
3099
3369
  if (expression.computed === true) this.walkExpression(expression.property);
3100
3370
  }
3101
3371
 
3372
+ /**
3373
+ * @param {ThisExpression} expression this expression
3374
+ */
3102
3375
  walkThisExpression(expression) {
3103
3376
  this.callHooksForName(this.hooks.expression, "this", expression);
3104
3377
  }
3105
3378
 
3379
+ /**
3380
+ * @param {Identifier} expression identifier
3381
+ */
3106
3382
  walkIdentifier(expression) {
3107
3383
  this.callHooksForName(this.hooks.expression, expression.name, expression);
3108
3384
  }
3109
3385
 
3110
3386
  /**
3111
- * @param {MetaPropertyNode} metaProperty meta property
3387
+ * @param {MetaProperty} metaProperty meta property
3112
3388
  */
3113
3389
  walkMetaProperty(metaProperty) {
3114
3390
  this.hooks.expression.for(getRootName(metaProperty)).call(metaProperty);
@@ -3128,7 +3404,7 @@ class JavascriptParser extends Parser {
3128
3404
  * @template T
3129
3405
  * @template R
3130
3406
  * @param {HookMap<SyncBailHook<T, R>>} hookMap hooks the should be called
3131
- * @param {MemberExpressionNode} expr expression info
3407
+ * @param {MemberExpression} expr expression info
3132
3408
  * @param {function(string, string | ScopeInfo | VariableInfo, function(): string[]): any} fallback callback when variable in not handled by hooks
3133
3409
  * @param {function(string): any} defined callback when variable is defined
3134
3410
  * @param {AsArray<T>} args args for the hook
@@ -3292,6 +3568,30 @@ class JavascriptParser extends Parser {
3292
3568
  this.scope = oldScope;
3293
3569
  }
3294
3570
 
3571
+ inClassScope(hasThis, params, fn) {
3572
+ const oldScope = this.scope;
3573
+ this.scope = {
3574
+ topLevelScope: oldScope.topLevelScope,
3575
+ inTry: false,
3576
+ inShorthand: false,
3577
+ isStrict: oldScope.isStrict,
3578
+ isAsmJs: oldScope.isAsmJs,
3579
+ definitions: oldScope.definitions.createChild()
3580
+ };
3581
+
3582
+ if (hasThis) {
3583
+ this.undefineVariable("this");
3584
+ }
3585
+
3586
+ this.enterPatterns(params, (ident, pattern) => {
3587
+ this.defineVariable(ident);
3588
+ });
3589
+
3590
+ fn();
3591
+
3592
+ this.scope = oldScope;
3593
+ }
3594
+
3295
3595
  inFunctionScope(hasThis, params, fn) {
3296
3596
  const oldScope = this.scope;
3297
3597
  this.scope = {
@@ -3385,12 +3685,20 @@ class JavascriptParser extends Parser {
3385
3685
  }
3386
3686
  }
3387
3687
 
3688
+ /**
3689
+ * @param {Identifier} pattern identifier pattern
3690
+ * @param {TODO} onIdent callback
3691
+ */
3388
3692
  enterIdentifier(pattern, onIdent) {
3389
3693
  if (!this.callHooksForName(this.hooks.pattern, pattern.name, pattern)) {
3390
3694
  onIdent(pattern.name, pattern);
3391
3695
  }
3392
3696
  }
3393
3697
 
3698
+ /**
3699
+ * @param {ObjectPattern} pattern object pattern
3700
+ * @param {TODO} onIdent callback
3701
+ */
3394
3702
  enterObjectPattern(pattern, onIdent) {
3395
3703
  for (
3396
3704
  let propIndex = 0, len = pattern.properties.length;
@@ -3402,6 +3710,10 @@ class JavascriptParser extends Parser {
3402
3710
  }
3403
3711
  }
3404
3712
 
3713
+ /**
3714
+ * @param {ArrayPattern} pattern object pattern
3715
+ * @param {TODO} onIdent callback
3716
+ */
3405
3717
  enterArrayPattern(pattern, onIdent) {
3406
3718
  for (
3407
3719
  let elementIndex = 0, len = pattern.elements.length;
@@ -3409,20 +3721,29 @@ class JavascriptParser extends Parser {
3409
3721
  elementIndex++
3410
3722
  ) {
3411
3723
  const element = pattern.elements[elementIndex];
3724
+ // TODO check on `null`?
3412
3725
  this.enterPattern(element, onIdent);
3413
3726
  }
3414
3727
  }
3415
3728
 
3729
+ /**
3730
+ * @param {RestElement} pattern object pattern
3731
+ * @param {TODO} onIdent callback
3732
+ */
3416
3733
  enterRestElement(pattern, onIdent) {
3417
3734
  this.enterPattern(pattern.argument, onIdent);
3418
3735
  }
3419
3736
 
3737
+ /**
3738
+ * @param {AssignmentPattern} pattern object pattern
3739
+ * @param {TODO} onIdent callback
3740
+ */
3420
3741
  enterAssignmentPattern(pattern, onIdent) {
3421
3742
  this.enterPattern(pattern.left, onIdent);
3422
3743
  }
3423
3744
 
3424
3745
  /**
3425
- * @param {ExpressionNode} expression expression node
3746
+ * @param {Expression} expression expression node
3426
3747
  * @returns {BasicEvaluatedExpression} evaluation result
3427
3748
  */
3428
3749
  evaluateExpression(expression) {
@@ -3444,6 +3765,10 @@ class JavascriptParser extends Parser {
3444
3765
  .setExpression(expression);
3445
3766
  }
3446
3767
 
3768
+ /**
3769
+ * @param {Expression} expression expression
3770
+ * @returns {string} parsed string
3771
+ */
3447
3772
  parseString(expression) {
3448
3773
  switch (expression.type) {
3449
3774
  case "BinaryExpression":
@@ -3552,7 +3877,7 @@ class JavascriptParser extends Parser {
3552
3877
  source = source.toString("utf-8");
3553
3878
  }
3554
3879
  if (typeof source === "object") {
3555
- ast = /** @type {ProgramNode} */ (source);
3880
+ ast = /** @type {Program} */ (source);
3556
3881
  comments = source.comments;
3557
3882
  } else {
3558
3883
  comments = [];
@@ -3620,7 +3945,7 @@ class JavascriptParser extends Parser {
3620
3945
  }
3621
3946
 
3622
3947
  /**
3623
- * @param {ExpressionNode | DeclarationNode | PrivateIdentifierNode | null | undefined} expr an expression
3948
+ * @param {Expression | Declaration | PrivateIdentifier | null | undefined} expr an expression
3624
3949
  * @param {number} commentsStartPos source position from which annotation comments are checked
3625
3950
  * @returns {boolean} true, when the expression is pure
3626
3951
  */
@@ -3638,21 +3963,34 @@ class JavascriptParser extends Parser {
3638
3963
  return false;
3639
3964
  }
3640
3965
  const items =
3641
- /** @type {(MethodDefinitionNode | PropertyDefinitionNode)[]} */ (
3642
- expr.body.body
3643
- );
3644
- return items.every(
3645
- item =>
3646
- (!item.computed ||
3647
- !item.key ||
3648
- this.isPure(item.key, item.range[0])) &&
3649
- (!item.static ||
3650
- !item.value ||
3651
- this.isPure(
3652
- item.value,
3653
- item.key ? item.key.range[1] : item.range[0]
3654
- ))
3655
- );
3966
+ /** @type {TODO[]} */
3967
+ (expr.body.body);
3968
+ return items.every(item => {
3969
+ if (
3970
+ item.computed &&
3971
+ item.key &&
3972
+ !this.isPure(item.key, item.range[0])
3973
+ ) {
3974
+ return false;
3975
+ }
3976
+
3977
+ if (
3978
+ item.static &&
3979
+ item.value &&
3980
+ !this.isPure(
3981
+ item.value,
3982
+ item.key ? item.key.range[1] : item.range[0]
3983
+ )
3984
+ ) {
3985
+ return false;
3986
+ }
3987
+
3988
+ if (item.type === "StaticBlock") {
3989
+ return false;
3990
+ }
3991
+
3992
+ return true;
3993
+ });
3656
3994
  }
3657
3995
 
3658
3996
  case "FunctionDeclaration":
@@ -3703,6 +4041,10 @@ class JavascriptParser extends Parser {
3703
4041
  return !evaluated.couldHaveSideEffects();
3704
4042
  }
3705
4043
 
4044
+ /**
4045
+ * @param {Range} range range
4046
+ * @returns {TODO[]} comments in the range
4047
+ */
3706
4048
  getComments(range) {
3707
4049
  const [rangeStart, rangeEnd] = range;
3708
4050
  const compare = (comment, needle) => comment.range[0] - needle;
@@ -3790,6 +4132,9 @@ class JavascriptParser extends Parser {
3790
4132
  this.scope.definitions.set(name, newInfo);
3791
4133
  }
3792
4134
 
4135
+ /**
4136
+ * @param {string} name variable name
4137
+ */
3793
4138
  defineVariable(name) {
3794
4139
  const oldInfo = this.scope.definitions.get(name);
3795
4140
  // Don't redefine variable in same scope to keep existing tags
@@ -3798,10 +4143,17 @@ class JavascriptParser extends Parser {
3798
4143
  this.scope.definitions.set(name, this.scope);
3799
4144
  }
3800
4145
 
4146
+ /**
4147
+ * @param {string} name variable name
4148
+ */
3801
4149
  undefineVariable(name) {
3802
4150
  this.scope.definitions.delete(name);
3803
4151
  }
3804
4152
 
4153
+ /**
4154
+ * @param {string} name variable name
4155
+ * @returns {boolean} true, when variable is defined
4156
+ */
3805
4157
  isVariableDefined(name) {
3806
4158
  const info = this.scope.definitions.get(name);
3807
4159
  if (info === undefined) return false;
@@ -3844,10 +4196,18 @@ class JavascriptParser extends Parser {
3844
4196
  }
3845
4197
  }
3846
4198
 
4199
+ /**
4200
+ * @param {TagInfo} tagInfo tag info
4201
+ * @returns {VariableInfo} variable info
4202
+ */
3847
4203
  evaluatedVariable(tagInfo) {
3848
4204
  return new VariableInfo(this.scope, undefined, tagInfo);
3849
4205
  }
3850
4206
 
4207
+ /**
4208
+ * @param {Range} range range of the comment
4209
+ * @returns {TODO} TODO
4210
+ */
3851
4211
  parseCommentOptions(range) {
3852
4212
  const comments = this.getComments(range);
3853
4213
  if (comments.length === 0) {
@@ -3882,8 +4242,8 @@ class JavascriptParser extends Parser {
3882
4242
  }
3883
4243
 
3884
4244
  /**
3885
- * @param {MemberExpressionNode} expression a member expression
3886
- * @returns {{ members: string[], object: ExpressionNode | SuperNode, membersOptionals: boolean[] }} member names (reverse order) and remaining object
4245
+ * @param {MemberExpression} expression a member expression
4246
+ * @returns {{ members: string[], object: Expression | Super, membersOptionals: boolean[] }} member names (reverse order) and remaining object
3887
4247
  */
3888
4248
  extractMemberExpressionChain(expression) {
3889
4249
  /** @type {AnyNode} */
@@ -3927,11 +4287,11 @@ class JavascriptParser extends Parser {
3927
4287
  return { info, name };
3928
4288
  }
3929
4289
 
3930
- /** @typedef {{ type: "call", call: CallExpressionNode, calleeName: string, rootInfo: string | VariableInfo, getCalleeMembers: () => string[], name: string, getMembers: () => string[], getMembersOptionals: () => boolean[]}} CallExpressionInfo */
4290
+ /** @typedef {{ type: "call", call: CallExpression, calleeName: string, rootInfo: string | VariableInfo, getCalleeMembers: () => string[], name: string, getMembers: () => string[], getMembersOptionals: () => boolean[]}} CallExpressionInfo */
3931
4291
  /** @typedef {{ type: "expression", rootInfo: string | VariableInfo, name: string, getMembers: () => string[], getMembersOptionals: () => boolean[]}} ExpressionExpressionInfo */
3932
4292
 
3933
4293
  /**
3934
- * @param {MemberExpressionNode} expression a member expression
4294
+ * @param {MemberExpression} expression a member expression
3935
4295
  * @param {number} allowedTypes which types should be returned, presented in bit mask
3936
4296
  * @returns {CallExpressionInfo | ExpressionExpressionInfo | undefined} expression info
3937
4297
  */
@@ -3988,7 +4348,7 @@ class JavascriptParser extends Parser {
3988
4348
  }
3989
4349
 
3990
4350
  /**
3991
- * @param {MemberExpressionNode} expression an expression
4351
+ * @param {MemberExpression} expression an expression
3992
4352
  * @returns {{ name: string, rootInfo: ExportedVariableInfo, getMembers: () => string[]}} name info
3993
4353
  */
3994
4354
  getNameForExpression(expression) {
@@ -4001,7 +4361,7 @@ class JavascriptParser extends Parser {
4001
4361
  /**
4002
4362
  * @param {string} code source code
4003
4363
  * @param {ParseOptions} options parsing options
4004
- * @returns {ProgramNode} parsed ast
4364
+ * @returns {Program} parsed ast
4005
4365
  */
4006
4366
  static _parse(code, options) {
4007
4367
  const type = options ? options.sourceType : "module";
@@ -4045,7 +4405,7 @@ class JavascriptParser extends Parser {
4045
4405
  throw error;
4046
4406
  }
4047
4407
 
4048
- return /** @type {ProgramNode} */ (ast);
4408
+ return /** @type {Program} */ (ast);
4049
4409
  }
4050
4410
  }
4051
4411