Skip to content

Commit 9f9e20c

Browse files
committed
Limit getTypeReferenceType to two passes
1 parent 471e680 commit 9f9e20c

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/compiler/checker.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6828,6 +6828,7 @@ namespace ts {
68286828

68296829
function getTypeReferenceType(node: TypeReferenceType, symbol: Symbol) {
68306830
const typeArguments = typeArgumentsFromTypeReferenceNode(node); // Do unconditionally so we mark type arguments as referenced.
6831+
let secondPass = true;
68316832
let fallbackType: Type = unknownType;
68326833
while (true) {
68336834
if (symbol === unknownSymbol) {
@@ -6844,18 +6845,22 @@ namespace ts {
68446845

68456846
if (symbol.flags & SymbolFlags.Value && node.kind === SyntaxKind.JSDocTypeReference) {
68466847
// A JSDocTypeReference may have resolved to a value (as opposed to a type). If
6847-
// the value has a construct signature, we use the return type of the construct
6848-
// signature as the type; otherwise, the type of this reference is just the type
6849-
// of the value we resolved to.
6848+
// the symbol is a constructor function, return the inferred class type; otherwise,
6849+
// the type of this reference is just the type of the value we resolved to.
68506850
if (symbol.flags & SymbolFlags.Function && (symbol.members || getJSDocClassTag(symbol.valueDeclaration))) {
68516851
return getInferredClassType(symbol);
68526852
}
68536853

6854-
fallbackType = getTypeOfSymbol(symbol);
6854+
// Stop if this is the second pass
6855+
if (secondPass) {
6856+
return fallbackType;
6857+
}
68556858

68566859
// Try to use the symbol of the type (if present) to get a better type on the
6857-
// next pass.
6860+
// second pass.
6861+
fallbackType = getTypeOfSymbol(symbol);
68586862
symbol = fallbackType.symbol || unknownSymbol;
6863+
secondPass = true;
68596864
continue;
68606865
}
68616866

0 commit comments

Comments
 (0)