Skip to content

Commit

Permalink
Check for class expressions in inspectDeclarator and inspectClassMethod
Browse files Browse the repository at this point in the history
  • Loading branch information
MartijnWelker committed Nov 20, 2019
1 parent 70152ff commit b366314
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions nginject.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ function inspectAssignment(path, ctx){

function inspectDeclarator(path, ctx){
const node = path.node;
if(!isFunctionExpressionOrArrow(node.init)){
if(!isFunctionExpressionOrArrow(node.init) && !t.isClassExpression(node.init)){
return;
}

Expand Down Expand Up @@ -270,7 +270,14 @@ function inspectClassMethod(path, ctx){
const ancestry = path.getAncestry();
for(var i=0; i < ancestry.length; i++){
let ancestor = ancestry[i];
if(ancestor.isClassDeclaration()){

// Adds the variable declaration of 'MyClass' to the suspects in the case of
// let MyClass = class MyClass {
// /* @ngInject */
// constructor() {
// }
// }
if(ancestor.isClassDeclaration() || ancestor.isClassExpression()){
addSuspect(ancestor, ctx, !annotation);
return;
}
Expand Down

0 comments on commit b366314

Please sign in to comment.