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 {
56855685 }
56865686
56875687 function reportCircularityError(symbol: Symbol) {
5688+ const declaration = <VariableLikeDeclaration>symbol.valueDeclaration;
56885689 // Check if variable has type annotation that circularly references the variable itself
5689- if (getEffectiveTypeAnnotationNode(<VariableLikeDeclaration>symbol.valueDeclaration )) {
5690+ if (getEffectiveTypeAnnotationNode(declaration )) {
56905691 error(symbol.valueDeclaration, Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation,
56915692 symbolToString(symbol));
56925693 return errorType;
56935694 }
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 ) {
56965697 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,
56975698 symbolToString(symbol));
56985699 }
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.
56995703 return anyType;
57005704 }
57015705
You can’t perform that action at this time.
0 commit comments