fix(39373): add diagnostic message about using a private name for class declarations without name (#39567)

This commit is contained in:
Alexander T
2020-07-17 03:05:33 +03:00
committed by GitHub
parent 1d671c3588
commit 4e24b1b00d
7 changed files with 100 additions and 2 deletions

View File

@@ -3057,6 +3057,10 @@
"category": "Error",
"code": 4020
},
"'extends' clause of exported class has or is using private name '{0}'.": {
"category": "Error",
"code": 4021
},
"'extends' clause of exported interface '{0}' has or is using private name '{1}'.": {
"category": "Error",
"code": 4022

View File

@@ -447,11 +447,12 @@ namespace ts {
function getHeritageClauseVisibilityError(): SymbolAccessibilityDiagnostic {
let diagnosticMessage: DiagnosticMessage;
// Heritage clause is written by user so it can always be named
if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) {
if (isClassDeclaration(node.parent.parent)) {
// Class or Interface implemented/extended is inaccessible
diagnosticMessage = isHeritageClause(node.parent) && node.parent.token === SyntaxKind.ImplementsKeyword ?
Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 :
Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1;
node.parent.parent.name ? Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1 :
Diagnostics.extends_clause_of_exported_class_has_or_is_using_private_name_0;
}
else {
// interface is inaccessible