File tree 1 file changed +14
-2
lines changed 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -11635,7 +11635,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
11635
11635
return getTypeOfFuncClassEnumModule(symbol);
11636
11636
}
11637
11637
11638
- if (checkMode !== CheckMode.Normal && checkMode) {
11638
+ // When trying to get the *contextual* type of a binding element, it's possible to fall in a loop and therefore
11639
+ // end up in a circularity-like situation. This is not a true circularity so we should not report such an error.
11640
+ // For example, here the looping could happen when trying to get the type of `a` (binding element):
11641
+ //
11642
+ // const { a, b = a } = { a: 0 }
11643
+ //
11644
+ if (isBindingElement(declaration) && checkMode === CheckMode.Contextual) {
11639
11645
return anyType;
11640
11646
}
11641
11647
return reportCircularityError(symbol);
@@ -11711,7 +11717,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
11711
11717
return getTypeOfFuncClassEnumModule(symbol);
11712
11718
}
11713
11719
11714
- if (checkMode !== CheckMode.Normal && checkMode) {
11720
+ // When trying to get the *contextual* type of a binding element, it's possible to fall in a loop and therefore
11721
+ // end up in a circularity-like situation. This is not a true circularity so we should not report such an error.
11722
+ // For example, here the looping could happen when trying to get the type of `a` (binding element):
11723
+ //
11724
+ // const { a, b = a } = { a: 0 }
11725
+ //
11726
+ if (isBindingElement(declaration) && checkMode === CheckMode.Contextual) {
11715
11727
return type;
11716
11728
}
11717
11729
return reportCircularityError(symbol);
You can’t perform that action at this time.
0 commit comments