Skip to content

Commit e305de1

Browse files
committed
Workaround to match previous type writer output
1 parent 186f525 commit e305de1

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

src/compiler/checker.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12002,10 +12002,6 @@ module ts {
1200212002
return unknownType;
1200312003
}
1200412004

12005-
if (isClassExtendsExpressionWithTypeArguments(node)) {
12006-
return getBaseTypes(<InterfaceType>getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0];
12007-
}
12008-
1200912005
if (isTypeNode(node)) {
1201012006
return getTypeFromTypeNode(<TypeNode>node);
1201112007
}
@@ -12014,6 +12010,12 @@ module ts {
1201412010
return getTypeOfExpression(<Expression>node);
1201512011
}
1201612012

12013+
if (isClassExtendsExpressionWithTypeArguments(node)) {
12014+
// A SyntaxKind.ExpressionWithTypeArguments is considered a type node, except when it occurs in the
12015+
// extends clause of a class. We handle that case here.
12016+
return getBaseTypes(<InterfaceType>getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0];
12017+
}
12018+
1201712019
if (isTypeDeclaration(node)) {
1201812020
// In this case, we call getSymbolOfNode instead of getSymbolInfo because it is a declaration
1201912021
let symbol = getSymbolOfNode(node);

src/harness/typeWriter.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ class TypeWriterWalker {
4141
var lineAndCharacter = this.currentSourceFile.getLineAndCharacterOfPosition(actualPos);
4242
var sourceText = ts.getTextOfNodeFromSourceText(this.currentSourceFile.text, node);
4343

44-
var type = this.checker.getTypeAtLocation(node);
44+
// Workaround to ensure we output 'C' instead of 'typeof C' for base class expressions
45+
// var type = this.checker.getTypeAtLocation(node);
46+
var type = node.parent && ts.isClassExtendsExpressionWithTypeArguments(node.parent) && this.checker.getTypeAtLocation(node.parent) || this.checker.getTypeAtLocation(node);
47+
4548
ts.Debug.assert(type !== undefined, "type doesn't exist");
4649
var symbol = this.checker.getSymbolAtLocation(node);
4750

0 commit comments

Comments
 (0)