Skip to content

Commit 88c7149

Browse files
committed
Fix modifier checking
1 parent 7c48b0d commit 88c7149

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/compiler/checker.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -45421,8 +45421,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4542145421
if (node.kind !== SyntaxKind.EnumDeclaration && node.kind !== SyntaxKind.TypeParameter) {
4542245422
return grammarErrorOnNode(node, Diagnostics.A_class_member_cannot_have_the_0_keyword, tokenToString(SyntaxKind.ConstKeyword));
4542345423
}
45424-
if (node.kind === SyntaxKind.TypeParameter && !isFunctionLikeDeclaration(node.parent)) {
45425-
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_function_or_constructor, tokenToString(modifier.kind));
45424+
if (node.kind === SyntaxKind.TypeParameter && !(isFunctionLikeDeclaration(node.parent) || isClassDeclaration(node.parent))) {
45425+
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_function_method_or_class, tokenToString(modifier.kind));
4542645426
}
4542745427
break;
4542845428
case SyntaxKind.OverrideKeyword:

src/compiler/diagnosticMessages.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@
907907
"category": "Error",
908908
"code": 1276
909909
},
910-
"'{0}' modifier can only appear on a type parameter of a function or constructor": {
910+
"'{0}' modifier can only appear on a type parameter of a function, method or class": {
911911
"category": "Error",
912912
"code": 1277
913913
},

0 commit comments

Comments
 (0)