@@ -61,7 +61,7 @@ namespace ts {
61
61
let currentSourceFile : SourceFile ;
62
62
let currentNamespace : ModuleDeclaration ;
63
63
let currentNamespaceContainerName : Identifier ;
64
- let currentScope : SourceFile | Block | ModuleBlock | CaseBlock ;
64
+ let currentScope : SourceFile | Block | ModuleBlock | CaseBlock | ClassDeclaration ;
65
65
let currentScopeFirstDeclarationsOfName : UnderscoreEscapedMap < Node > | undefined ;
66
66
67
67
/**
@@ -166,6 +166,9 @@ namespace ts {
166
166
167
167
case SyntaxKind . ClassDeclaration :
168
168
case SyntaxKind . FunctionDeclaration :
169
+ if ( isClassDeclaration ( node ) ) {
170
+ currentScope = node ;
171
+ }
169
172
if ( hasModifier ( node , ModifierFlags . Ambient ) ) {
170
173
break ;
171
174
}
@@ -1971,13 +1974,13 @@ namespace ts {
1971
1974
function serializeTypeReferenceNode ( node : TypeReferenceNode ) : SerializedTypeNode {
1972
1975
// node might be a reference to type variable, which can be scoped to a class declaration, in addition to the regular
1973
1976
// TypeScript scopes. Walk up the AST to find the next class and use that as the lookup scope.
1974
- let scope : Node = node ;
1975
- while ( scope . parent && scope !== currentScope ) {
1976
- scope = scope . parent ;
1977
- if ( isClassDeclaration ( scope ) ) {
1978
- break ;
1979
- }
1980
- }
1977
+ let scope : Node = currentScope ;
1978
+ // while (scope.parent && scope !== currentScope) {
1979
+ // scope = scope.parent;
1980
+ // if (isClassDeclaration(scope)) {
1981
+ // break;
1982
+ // }
1983
+ // }
1981
1984
const kind = resolver . getTypeReferenceSerializationKind ( node . typeName , scope ) ;
1982
1985
switch ( kind ) {
1983
1986
case TypeReferenceSerializationKind . Unknown :
0 commit comments