From 8c270757b21e62132f68e6b2f08dc66fe5e75f98 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 7 Oct 2021 08:41:06 -0700 Subject: [PATCH] In plain JS files, only suggestion did-you-mean errors (#46151) They will have code fixes, and are tuned for high precision. Others are not. --- src/compiler/checker.ts | 2 +- tests/cases/fourslash/codeFixSpellingJs9.ts | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/codeFixSpellingJs9.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index fbfbfc9b3d6..3d54f2e9db5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -28454,7 +28454,7 @@ namespace ts { if (relatedInfo) { addRelatedInfo(resultDiagnostic, relatedInfo); } - addErrorOrSuggestion(!isUncheckedJS, resultDiagnostic); + addErrorOrSuggestion(!isUncheckedJS || errorInfo.code !== Diagnostics.Property_0_may_not_exist_on_type_1_Did_you_mean_2.code, resultDiagnostic); } function containerSeemsToBeEmptyDomElement(containingType: Type) { diff --git a/tests/cases/fourslash/codeFixSpellingJs9.ts b/tests/cases/fourslash/codeFixSpellingJs9.ts new file mode 100644 index 00000000000..74d78c827c2 --- /dev/null +++ b/tests/cases/fourslash/codeFixSpellingJs9.ts @@ -0,0 +1,10 @@ +/// + +// @allowjs: true +// @noEmit: true + +// @filename: noSuggestionWithoutDidYouMean.js +//// let a = {}; +//// console.log(a.apple); +verify.noErrors() +verify.getSuggestionDiagnostics([])