diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e1aad0b3835..f9affcad6bc 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13684,6 +13684,10 @@ namespace ts { break; case SyntaxKind.BindingElement: diagnostic = Diagnostics.Binding_element_0_implicitly_has_an_1_type; + if (!noImplicitAny) { + // Don't issue a suggestion for binding elements since the codefix doesn't yet support them. + return; + } break; case SyntaxKind.JSDocFunctionType: error(declaration, Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); diff --git a/tests/cases/fourslash/codeFixInferFromUsageBindingElement.ts b/tests/cases/fourslash/codeFixInferFromUsageBindingElement.ts new file mode 100644 index 00000000000..e60b7efa3b9 --- /dev/null +++ b/tests/cases/fourslash/codeFixInferFromUsageBindingElement.ts @@ -0,0 +1,8 @@ +/// +////function f([car, cdr]) { +//// return car + cdr + 1 +////} + +// When inferFromUsage supports it, it should infer number for both variables +verify.getSuggestionDiagnostics([]); +