Improve error message for unserializable private and protected class members (#59229)

This commit is contained in:
Wesley Wigham
2024-07-11 11:05:52 -07:00
committed by GitHub
parent e450c463c6
commit 46410044ad
78 changed files with 3360 additions and 892 deletions

View File

@@ -4212,7 +4212,7 @@
"category": "Error",
"code": 4092
},
"Property '{0}' of exported class expression may not be private or protected.": {
"Property '{0}' of exported anonymous class type may not be private or protected.": {
"category": "Error",
"code": 4094
},

View File

@@ -357,7 +357,10 @@ export function transformDeclarations(context: TransformationContext) {
function reportPrivateInBaseOfClassExpression(propertyName: string) {
if (errorNameNode || errorFallbackNode) {
context.addDiagnostic(
createDiagnosticForNode((errorNameNode || errorFallbackNode)!, Diagnostics.Property_0_of_exported_class_expression_may_not_be_private_or_protected, propertyName),
addRelatedInfo(
createDiagnosticForNode((errorNameNode || errorFallbackNode)!, Diagnostics.Property_0_of_exported_anonymous_class_type_may_not_be_private_or_protected, propertyName),
...(isVariableDeclaration((errorNameNode || errorFallbackNode)!.parent) ? [createDiagnosticForNode((errorNameNode || errorFallbackNode)!, Diagnostics.Add_a_type_annotation_to_the_variable_0, errorDeclarationNameWithFallback())] : []),
),
);
}
}