Skip to content

Commit

Permalink
Minor cleanup of resolveName for decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuckton committed Mar 20, 2015
1 parent 0fb624a commit 2078aff
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,24 +417,25 @@ module ts {
}
break;
case SyntaxKind.Decorator:
// Decorators are resolved at the class declaration as that point where they are evaluated in the emit:
// Decorators are resolved at the class declaration. Resolving at the parameter
// or member would result in looking up locals in the method.
//
// function y() {}
// class C {
// method(@y x, y) {} // <-- All references to decorators should occur at the class declaration
// method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter.
// }
//
let parent = location.parent;
if (parent && parent.kind === SyntaxKind.Parameter) {
parent = parent.parent;
if (location.parent && location.parent.kind === SyntaxKind.Parameter) {
location = location.parent;
}
if (parent && isClassElement(parent)) {
parent = parent.parent;
}
if (parent) {
lastLocation = location;
location = parent;
continue;
//
// function y() {}
// class C {
// @y method(x, y) {} // <-- decorator y should be resolved at the class declaration, not the method.
// }
//
if (location.parent && isClassElement(location.parent)) {
location = location.parent;

This comment has been minimized.

Copy link
@JsonFreeman

JsonFreeman Mar 20, 2015

Contributor

This is much better, thanks!

}
break;
}
Expand Down

0 comments on commit 2078aff

Please sign in to comment.