More did-you-mean errors on classes in plain JS (#49827)

This commit is contained in:
Nathan Shively-Sanders authored and GitHub committed 2023-09-22 16:12:21 -07:00
1 parent da8b54d831
commit 982f8be6f2
2 files changed
+77 -9

No files matched your search

+6 -2
View File
@@ -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;