Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit 83dbabb

Browse files
armano2platinumazure
authored andcommitted
Fix: visiting typeParameters in expressions (#565)
* Fix: missing typeParameters in expressions * ignoreEval is always set to true, than we can ignore this case
1 parent c19e479 commit 83dbabb

File tree

4 files changed

+550
-0
lines changed

4 files changed

+550
-0
lines changed

analyze-scope.js

+42
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,20 @@ class Referencer extends OriginalReferencer {
218218
super.visitClass(node);
219219
}
220220

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+
221235
/**
222236
* Override.
223237
* Don't create the reference object in the type mode.
@@ -286,6 +300,34 @@ class Referencer extends OriginalReferencer {
286300
this.typeMode = upperTypeMode;
287301
}
288302

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+
this.visit(node.callee);
326+
if (node.arguments) {
327+
node.arguments.forEach(this.visit, this);
328+
}
329+
}
330+
289331
/**
290332
* Define the variable of this function declaration only once.
291333
* Because to avoid confusion of `no-redeclare` rule by overloading.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const a, b, c, d, e, f
2+
3+
new foo<Bar>(a, b, c);
4+
5+
baz<Bar>(d, e, f);

0 commit comments

Comments
 (0)