diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index ebf5e662517..6d724750b00 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -61,7 +61,7 @@ namespace ts { let currentSourceFile: SourceFile; let currentNamespace: ModuleDeclaration; let currentNamespaceContainerName: Identifier; - let currentScope: SourceFile | Block | ModuleBlock | CaseBlock; + let currentScope: SourceFile | Block | ModuleBlock | CaseBlock | ClassDeclaration; let currentScopeFirstDeclarationsOfName: UnderscoreEscapedMap | undefined; /** @@ -166,6 +166,9 @@ namespace ts { case SyntaxKind.ClassDeclaration: case SyntaxKind.FunctionDeclaration: + if (isClassDeclaration(node)) { + currentScope = node; + } if (hasModifier(node, ModifierFlags.Ambient)) { break; } @@ -1971,13 +1974,13 @@ namespace ts { function serializeTypeReferenceNode(node: TypeReferenceNode): SerializedTypeNode { // node might be a reference to type variable, which can be scoped to a class declaration, in addition to the regular // TypeScript scopes. Walk up the AST to find the next class and use that as the lookup scope. - let scope: Node = node; - while (scope.parent && scope !== currentScope) { - scope = scope.parent; - if (isClassDeclaration(scope)) { - break; - } - } + let scope: Node = currentScope; + // while (scope.parent && scope !== currentScope) { + // scope = scope.parent; + // if (isClassDeclaration(scope)) { + // break; + // } + // } const kind = resolver.getTypeReferenceSerializationKind(node.typeName, scope); switch (kind) { case TypeReferenceSerializationKind.Unknown: