Skip to content

Commit 9254767

Browse files
committed
Check for class expressions in inspectDeclarator and inspectClassMethod
1 parent 70152ff commit 9254767

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

nginject.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ function inspectAssignment(path, ctx){
227227

228228
function inspectDeclarator(path, ctx){
229229
const node = path.node;
230-
if(!isFunctionExpressionOrArrow(node.init)){
230+
if(!isFunctionExpressionOrArrow(node.init) && !t.isClassExpression(node.init)){
231231
return;
232232
}
233233

@@ -270,10 +270,17 @@ function inspectClassMethod(path, ctx){
270270
const ancestry = path.getAncestry();
271271
for(var i=0; i < ancestry.length; i++){
272272
let ancestor = ancestry[i];
273+
273274
if(ancestor.isClassDeclaration()){
274275
addSuspect(ancestor, ctx, !annotation);
275276
return;
276277
}
278+
279+
if (ancestor.isClassExpression()) {
280+
// Add the variable declaration of the class as suspect
281+
addSuspect(ancestor.parentPath.parentPath);
282+
return;
283+
}
277284
}
278285
}
279286

0 commit comments

Comments
 (0)