diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1748e660e9259..367e5ab1e81b1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -32306,9 +32306,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (file) { if (compilerOptions.checkJs === undefined && file.checkJsDirective === undefined && (file.scriptKind === ScriptKind.JS || file.scriptKind === ScriptKind.JSX)) { const declarationFile = forEach(suggestion?.declarations, getSourceFileOfNode); + const suggestionHasNoExtendsOrDecorators = !suggestion?.valueDeclaration + || !isClassLike(suggestion.valueDeclaration) + || suggestion.valueDeclaration.heritageClauses?.length + || classOrConstructorParameterIsDecorated(/*useLegacyDecorators*/ false, suggestion.valueDeclaration); return !(file !== declarationFile && !!declarationFile && isGlobalSourceFile(declarationFile)) - && !(excludeClasses && suggestion && suggestion.flags & SymbolFlags.Class) - && !(!!node && excludeClasses && isPropertyAccessExpression(node) && node.expression.kind === SyntaxKind.ThisKeyword); + && !(excludeClasses && suggestion && suggestion.flags & SymbolFlags.Class && suggestionHasNoExtendsOrDecorators) + && !(!!node && excludeClasses && isPropertyAccessExpression(node) && node.expression.kind === SyntaxKind.ThisKeyword && suggestionHasNoExtendsOrDecorators); } } return false; diff --git a/tests/cases/fourslash/codeFixSpellingJs9.ts b/tests/cases/fourslash/codeFixSpellingJs9.ts index 74d78c827c243..876d31caefac2 100644 --- a/tests/cases/fourslash/codeFixSpellingJs9.ts +++ b/tests/cases/fourslash/codeFixSpellingJs9.ts @@ -1,10 +1,74 @@ /// +// @allowJs: true +// @Filename: codeFixSpellingJs9.js +//// class C { +//// numble = 1 +//// mumble() { +//// return this.[|numbles|] +//// } +//// } +//// class D extends C { } +//// const c = new C() +//// c.[|numbles|] = 3 +//// c.[|mumbles|]() +//// const d = new D() +//// d.[|numbles|] = 4 +//// d.[|mumbles()|] +//// class Person { +//// getFavoriteColor() { +//// +//// } +//// } +//// +//// const person = new Person(); +//// person.[|getFavoriteColour|](); +//// person.[|getFavoriteColoxr|](); +//// function deco() { } +//// @deco +//// class Art { +//// style = true +//// } +//// const a = new Art() +//// a.[|stylo|] +//// @deco +//// class Double extends Art { } +//// const db = new Double() +//// db.[|stylo|] +verify.codeFixAll({ + fixId: "fixSpelling", + fixAllDescription: "Fix all detected spelling errors", + newFileContent: + `class C { + numble = 1 + mumble() { + return this.numble + } +} +class D extends C { } +const c = new C() +c.numble = 3 +c.mumble() +const d = new D() +d.numbles = 4 +d.mumbles() +class Person { + getFavoriteColor() { -// @allowjs: true -// @noEmit: true + } +} -// @filename: noSuggestionWithoutDidYouMean.js -//// let a = {}; -//// console.log(a.apple); -verify.noErrors() -verify.getSuggestionDiagnostics([]) +const person = new Person(); +person.getFavoriteColor(); +person.getFavoriteColor(); +function deco() { } +@deco +class Art { + style = true +} +const a = new Art() +a.stylo +@deco +class Double extends Art { } +const db = new Double() +db.stylo`, +});