File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -5685,17 +5685,21 @@ namespace ts {
5685
5685
}
5686
5686
5687
5687
function reportCircularityError(symbol: Symbol) {
5688
+ const declaration = <VariableLikeDeclaration>symbol.valueDeclaration;
5688
5689
// Check if variable has type annotation that circularly references the variable itself
5689
- if (getEffectiveTypeAnnotationNode(<VariableLikeDeclaration>symbol.valueDeclaration )) {
5690
+ if (getEffectiveTypeAnnotationNode(declaration )) {
5690
5691
error(symbol.valueDeclaration, Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation,
5691
5692
symbolToString(symbol));
5692
5693
return errorType;
5693
5694
}
5694
- // Otherwise variable has initializer that circularly references the variable itself
5695
- if (noImplicitAny) {
5695
+ // Check if variable has initializer that circularly references the variable itself
5696
+ if (noImplicitAny && (<HasInitializer>declaration).initializer ) {
5696
5697
error(symbol.valueDeclaration, Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer,
5697
5698
symbolToString(symbol));
5698
5699
}
5700
+ // Circularities could also result from parameters in function expressions that end up
5701
+ // having themselves as contextual types following type argument inference. In those cases
5702
+ // we have already reported an implicit any error so we don't report anything here.
5699
5703
return anyType;
5700
5704
}
5701
5705
You can’t perform that action at this time.
0 commit comments