@@ -526,6 +526,19 @@ module ts {
526526 // the *body* of the container.
527527 node = node . parent ;
528528 break ;
529+ case SyntaxKind . Decorator :
530+ // Decorators are always applied outside of the body of a class or method.
531+ if ( node . parent . kind === SyntaxKind . Parameter && isClassElement ( node . parent . parent ) ) {
532+ // If the decorator's parent is a Parameter, we resolve the this container from
533+ // the grandparent class declaration.
534+ node = node . parent . parent ;
535+ }
536+ else if ( isClassElement ( node . parent ) ) {
537+ // If the decorator's parent is a class element, we resolve the 'this' container
538+ // from the parent class declaration.
539+ node = node . parent ;
540+ }
541+ break ;
529542 case SyntaxKind . ArrowFunction :
530543 if ( ! includeArrowFunctions ) {
531544 continue ;
@@ -568,6 +581,19 @@ module ts {
568581 // the *body* of the container.
569582 node = node . parent ;
570583 break ;
584+ case SyntaxKind . Decorator :
585+ // Decorators are always applied outside of the body of a class or method.
586+ if ( node . parent . kind === SyntaxKind . Parameter && isClassElement ( node . parent . parent ) ) {
587+ // If the decorator's parent is a Parameter, we resolve the this container from
588+ // the grandparent class declaration.
589+ node = node . parent . parent ;
590+ }
591+ else if ( isClassElement ( node . parent ) ) {
592+ // If the decorator's parent is a class element, we resolve the 'this' container
593+ // from the parent class declaration.
594+ node = node . parent ;
595+ }
596+ break ;
571597 case SyntaxKind . FunctionDeclaration :
572598 case SyntaxKind . FunctionExpression :
573599 case SyntaxKind . ArrowFunction :
@@ -919,6 +945,7 @@ module ts {
919945 case SyntaxKind . MethodDeclaration :
920946 case SyntaxKind . GetAccessor :
921947 case SyntaxKind . SetAccessor :
948+ case SyntaxKind . MethodSignature :
922949 case SyntaxKind . IndexSignature :
923950 return true ;
924951 default :
0 commit comments