mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00:00
More did-you-mean errors on classes in plain JS (#49827)
This commit is contained in:
1 parent
da8b54d831
commit
982f8be6f2
2 files changed
+77
-9
No files matched your search
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user