@@ -218,6 +218,20 @@ class Referencer extends OriginalReferencer {
218
218
super . visitClass ( node ) ;
219
219
}
220
220
221
+ /**
222
+ * Visit typeParameters.
223
+ * @param {* } node The node to visit.
224
+ * @returns {void }
225
+ */
226
+ visitTypeParameters ( node ) {
227
+ if ( node . typeParameters ) {
228
+ const upperTypeMode = this . typeMode ;
229
+ this . typeMode = true ;
230
+ this . visit ( node . typeParameters ) ;
231
+ this . typeMode = upperTypeMode ;
232
+ }
233
+ }
234
+
221
235
/**
222
236
* Override.
223
237
* Don't create the reference object in the type mode.
@@ -286,6 +300,41 @@ class Referencer extends OriginalReferencer {
286
300
this . typeMode = upperTypeMode ;
287
301
}
288
302
303
+ /**
304
+ * Visit new expression.
305
+ * @param {NewExpression } node The NewExpression node to visit.
306
+ * @returns {void }
307
+ */
308
+ NewExpression ( node ) {
309
+ this . visitTypeParameters ( node ) ;
310
+ this . visit ( node . callee ) ;
311
+ if ( node . arguments ) {
312
+ node . arguments . forEach ( this . visit , this ) ;
313
+ }
314
+ }
315
+
316
+ /**
317
+ * Override.
318
+ * Visit call expression.
319
+ * @param {CallExpression } node The CallExpression node to visit.
320
+ * @returns {void }
321
+ */
322
+ CallExpression ( node ) {
323
+ this . visitTypeParameters ( node ) ;
324
+
325
+ // Check this is direct call to eval
326
+ if ( ! this . scopeManager . __ignoreEval ( ) && node . callee . type === "Identifier" && node . callee . name === "eval" ) {
327
+
328
+ // NOTE: This should be `variableScope`. Since direct eval call always creates Lexical environment and
329
+ // let / const should be enclosed into it. Only VariableDeclaration affects on the caller's environment.
330
+ this . currentScope ( ) . variableScope . __detectEval ( ) ;
331
+ }
332
+ this . visit ( node . callee ) ;
333
+ if ( node . arguments ) {
334
+ node . arguments . forEach ( this . visit , this ) ;
335
+ }
336
+ }
337
+
289
338
/**
290
339
* Define the variable of this function declaration only once.
291
340
* Because to avoid confusion of `no-redeclare` rule by overloading.
0 commit comments