Merge pull request #28609 from ajafff/class-decorator-generics

resolve TypeReference in class decorator at parent of class
This commit is contained in:
Ron Buckton
2019-03-19 15:46:58 -07:00
committed by GitHub
5 changed files with 109 additions and 1 deletions

View File

@@ -1474,7 +1474,14 @@ namespace ts {
// @y method(x, y) {} // <-- decorator y should be resolved at the class declaration, not the method.
// }
//
if (location.parent && isClassElement(location.parent)) {
// class Decorators are resolved outside of the class to avoid referencing type parameters of that class.
//
// type T = number;
// declare function y(x: T): any;
// @param(1 as T) // <-- T should resolve to the type alias outside of class C
// class C<T> {}
if (location.parent && (isClassElement(location.parent) || location.parent.kind === SyntaxKind.ClassDeclaration)) {
location = location.parent;
}
break;