@@ -11808,7 +11808,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
11808
11808
// contextual type or, if the element itself is a binding pattern, with the type implied by that binding
11809
11809
// pattern.
11810
11810
const contextualType = isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, /*includePatternInType*/ true, /*reportErrors*/ false) : unknownType;
11811
- return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, reportErrors ? CheckMode.Normal : CheckMode.Contextual , contextualType)));
11811
+ return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, CheckMode.Normal, contextualType)));
11812
11812
}
11813
11813
if (isBindingPattern(element.name)) {
11814
11814
return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors);
@@ -11985,24 +11985,24 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
11985
11985
return false;
11986
11986
}
11987
11987
11988
- function getTypeOfVariableOrParameterOrProperty(symbol: Symbol, checkMode?: CheckMode ): Type {
11988
+ function getTypeOfVariableOrParameterOrProperty(symbol: Symbol): Type {
11989
11989
const links = getSymbolLinks(symbol);
11990
11990
if (!links.type) {
11991
- const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol, checkMode );
11991
+ const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol);
11992
11992
// For a contextually typed parameter it is possible that a type has already
11993
11993
// been assigned (in assignTypeToParameterAndFixTypeParameters), and we want
11994
11994
// to preserve this type. In fact, we need to _prefer_ that type, but it won't
11995
11995
// be assigned until contextual typing is complete, so we need to defer in
11996
11996
// cases where contextual typing may take place.
11997
- if (!links.type && !isParameterOfContextSensitiveSignature(symbol) && !checkMode ) {
11997
+ if (!links.type && !isParameterOfContextSensitiveSignature(symbol)) {
11998
11998
links.type = type;
11999
11999
}
12000
12000
return type;
12001
12001
}
12002
12002
return links.type;
12003
12003
}
12004
12004
12005
- function getTypeOfVariableOrParameterOrPropertyWorker(symbol: Symbol, checkMode?: CheckMode ): Type {
12005
+ function getTypeOfVariableOrParameterOrPropertyWorker(symbol: Symbol): Type {
12006
12006
// Handle prototype property
12007
12007
if (symbol.flags & SymbolFlags.Prototype) {
12008
12008
return getTypeOfPrototypeProperty(symbol);
@@ -12045,16 +12045,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
12045
12045
if (symbol.flags & SymbolFlags.ValueModule && !(symbol.flags & SymbolFlags.Assignment)) {
12046
12046
return getTypeOfFuncClassEnumModule(symbol);
12047
12047
}
12048
-
12049
- // When trying to get the *contextual* type of a binding element, it's possible to fall in a loop and therefore
12050
- // end up in a circularity-like situation. This is not a true circularity so we should not report such an error.
12051
- // For example, here the looping could happen when trying to get the type of `a` (binding element):
12052
- //
12053
- // const { a, b = a } = { a: 0 }
12054
- //
12055
- if (isBindingElement(declaration) && checkMode === CheckMode.Contextual) {
12056
- return errorType;
12057
- }
12058
12048
return reportCircularityError(symbol);
12059
12049
}
12060
12050
let type: Type;
@@ -12127,16 +12117,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
12127
12117
if (symbol.flags & SymbolFlags.ValueModule && !(symbol.flags & SymbolFlags.Assignment)) {
12128
12118
return getTypeOfFuncClassEnumModule(symbol);
12129
12119
}
12130
-
12131
- // When trying to get the *contextual* type of a binding element, it's possible to fall in a loop and therefore
12132
- // end up in a circularity-like situation. This is not a true circularity so we should not report such an error.
12133
- // For example, here the looping could happen when trying to get the type of `a` (binding element):
12134
- //
12135
- // const { a, b = a } = { a: 0 }
12136
- //
12137
- if (isBindingElement(declaration) && checkMode === CheckMode.Contextual) {
12138
- return type;
12139
- }
12140
12120
return reportCircularityError(symbol);
12141
12121
}
12142
12122
return type;
@@ -12419,7 +12399,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
12419
12399
return getTypeOfSymbol(symbol);
12420
12400
}
12421
12401
12422
- function getTypeOfSymbol(symbol: Symbol, checkMode?: CheckMode ): Type {
12402
+ function getTypeOfSymbol(symbol: Symbol): Type {
12423
12403
const checkFlags = getCheckFlags(symbol);
12424
12404
if (checkFlags & CheckFlags.DeferredType) {
12425
12405
return getTypeOfSymbolWithDeferredType(symbol);
@@ -12434,7 +12414,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
12434
12414
return getTypeOfReverseMappedSymbol(symbol as ReverseMappedSymbol);
12435
12415
}
12436
12416
if (symbol.flags & (SymbolFlags.Variable | SymbolFlags.Property)) {
12437
- return getTypeOfVariableOrParameterOrProperty(symbol, checkMode );
12417
+ return getTypeOfVariableOrParameterOrProperty(symbol);
12438
12418
}
12439
12419
if (symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.Class | SymbolFlags.Enum | SymbolFlags.ValueModule)) {
12440
12420
return getTypeOfFuncClassEnumModule(symbol);
@@ -30072,8 +30052,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
30072
30052
}
30073
30053
}
30074
30054
30075
- function getNarrowedTypeOfSymbol(symbol: Symbol, location: Identifier, checkMode?: CheckMode ) {
30076
- const type = getTypeOfSymbol(symbol, checkMode );
30055
+ function getNarrowedTypeOfSymbol(symbol: Symbol, location: Identifier) {
30056
+ const type = getTypeOfSymbol(symbol);
30077
30057
const declaration = symbol.valueDeclaration;
30078
30058
if (declaration) {
30079
30059
// If we have a non-rest binding element with no initializer declared as a const variable or a const-like
@@ -30256,7 +30236,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
30256
30236
const localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
30257
30237
let declaration = localOrExportSymbol.valueDeclaration;
30258
30238
30259
- let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node, checkMode );
30239
+ let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node);
30260
30240
const assignmentKind = getAssignmentTargetKind(node);
30261
30241
30262
30242
if (assignmentKind) {
0 commit comments