Skip to content

Commit d65136f

Browse files
Added error message for private identifiers used with static decorators. There is no spec to go with this behavior as of yet.
1 parent 21a35c3 commit d65136f

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35993,6 +35993,9 @@ namespace ts {
3599335993
}
3599435994

3599535995
function checkClassDeclaration(node: ClassDeclaration) {
35996+
if (some(node.decorators) && some(node.members, p => hasStaticModifier(p) && isPrivateIdentifierClassElementDeclaration(p))) {
35997+
grammarErrorOnNode(node.decorators[0], Diagnostics.Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator);
35998+
}
3599635999
if (!node.name && !hasSyntacticModifier(node, ModifierFlags.Default)) {
3599736000
grammarErrorOnFirstToken(node, Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name);
3599836001
}

src/compiler/diagnosticMessages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6350,5 +6350,9 @@
63506350
"Invalid value for 'jsxFragmentFactory'. '{0}' is not a valid identifier or qualified-name.": {
63516351
"category": "Error",
63526352
"code": 18035
6353+
},
6354+
"Class decorators can't be used with static private identifier. Consider removing the experimental decorator.": {
6355+
"category": "Error",
6356+
"code": 18036
63536357
}
63546358
}

0 commit comments

Comments
 (0)