Skip to content

Commit b366314

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

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

nginject.js

Lines changed: 9 additions & 2 deletions
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,7 +270,14 @@ function inspectClassMethod(path, ctx){
270270
const ancestry = path.getAncestry();
271271
for(var i=0; i < ancestry.length; i++){
272272
let ancestor = ancestry[i];
273-
if(ancestor.isClassDeclaration()){
273+
274+
// Adds the variable declaration of 'MyClass' to the suspects in the case of
275+
// let MyClass = class MyClass {
276+
// /* @ngInject */
277+
// constructor() {
278+
// }
279+
// }
280+
if(ancestor.isClassDeclaration() || ancestor.isClassExpression()){
274281
addSuspect(ancestor, ctx, !annotation);
275282
return;
276283
}

0 commit comments

Comments
 (0)