mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 21:36:50 -05:00
Merge pull request #28609 from ajafff/class-decorator-generics
resolve TypeReference in class decorator at parent of class
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user