Skip to content

Commit 059fd2d

Browse files
committed
Never overwrite resolved type of symbol
1 parent b2b360a commit 059fd2d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/compiler/checker.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5425,7 +5425,16 @@ namespace ts {
54255425

54265426
function getTypeOfVariableOrParameterOrProperty(symbol: Symbol): Type {
54275427
const links = getSymbolLinks(symbol);
5428-
return links.type || (links.type = getTypeOfVariableOrParameterOrPropertyWorker(symbol));
5428+
if (!links.type) {
5429+
const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol);
5430+
// For a contextually typed parameter it is possible that a type has already
5431+
// been assigned (in assignTypeToParameterAndFixTypeParameters), and we want
5432+
// to preserve this type.
5433+
if (!links.type) {
5434+
links.type = type;
5435+
}
5436+
}
5437+
return links.type;
54295438
}
54305439

54315440
function getTypeOfVariableOrParameterOrPropertyWorker(symbol: Symbol) {
@@ -5469,7 +5478,7 @@ namespace ts {
54695478
if (symbol.flags & SymbolFlags.ValueModule) {
54705479
return getTypeOfFuncClassEnumModule(symbol);
54715480
}
5472-
return errorType;
5481+
return reportCircularityError(symbol);
54735482
}
54745483
let type: Type | undefined;
54755484
if (isInJSFile(declaration) &&
@@ -5528,7 +5537,7 @@ namespace ts {
55285537
if (symbol.flags & SymbolFlags.ValueModule) {
55295538
return getTypeOfFuncClassEnumModule(symbol);
55305539
}
5531-
type = reportCircularityError(symbol);
5540+
return reportCircularityError(symbol);
55325541
}
55335542
return type;
55345543
}

0 commit comments

Comments
 (0)