@@ -166,9 +166,6 @@ namespace ts {
166
166
167
167
case SyntaxKind . ClassDeclaration :
168
168
case SyntaxKind . FunctionDeclaration :
169
- if ( isClassDeclaration ( node ) ) {
170
- currentScope = node ;
171
- }
172
169
if ( hasModifier ( node , ModifierFlags . Ambient ) ) {
173
170
break ;
174
171
}
@@ -183,6 +180,10 @@ namespace ts {
183
180
// programs may also have an undefined name.
184
181
Debug . assert ( node . kind === SyntaxKind . ClassDeclaration || hasModifier ( node , ModifierFlags . Default ) ) ;
185
182
}
183
+ if ( isClassDeclaration ( node ) ) {
184
+ // XXX: should probably also cover interfaces and type aliases that can have type variables?
185
+ currentScope = node ;
186
+ }
186
187
187
188
break ;
188
189
}
@@ -1972,16 +1973,7 @@ namespace ts {
1972
1973
* @param node The type reference node.
1973
1974
*/
1974
1975
function serializeTypeReferenceNode ( node : TypeReferenceNode ) : SerializedTypeNode {
1975
- // node might be a reference to type variable, which can be scoped to a class declaration, in addition to the regular
1976
- // TypeScript scopes. Walk up the AST to find the next class and use that as the lookup scope.
1977
- let scope : Node = currentScope ;
1978
- // while (scope.parent && scope !== currentScope) {
1979
- // scope = scope.parent;
1980
- // if (isClassDeclaration(scope)) {
1981
- // break;
1982
- // }
1983
- // }
1984
- const kind = resolver . getTypeReferenceSerializationKind ( node . typeName , scope ) ;
1976
+ const kind = resolver . getTypeReferenceSerializationKind ( node . typeName , currentScope ) ;
1985
1977
switch ( kind ) {
1986
1978
case TypeReferenceSerializationKind . Unknown :
1987
1979
const serialized = serializeEntityNameAsExpression ( node . typeName , /*useFallback*/ true ) ;
0 commit comments