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

This commit is contained in:
Nathan Shively-Sanders
2023-09-22 16:12:21 -07:00
committed by GitHub
parent da8b54d831
commit 982f8be6f2
2 changed files with 77 additions and 9 deletions
+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;