Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix modifier checking
  • Loading branch information
ahejlsberg committed Dec 12, 2022
commit 88c71495a48c5e348a3103d925a7bf351e3993ac
4 changes: 2 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45421,8 +45421,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
if (node.kind !== SyntaxKind.EnumDeclaration && node.kind !== SyntaxKind.TypeParameter) {
return grammarErrorOnNode(node, Diagnostics.A_class_member_cannot_have_the_0_keyword, tokenToString(SyntaxKind.ConstKeyword));
}
if (node.kind === SyntaxKind.TypeParameter && !isFunctionLikeDeclaration(node.parent)) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_function_or_constructor, tokenToString(modifier.kind));
if (node.kind === SyntaxKind.TypeParameter && !(isFunctionLikeDeclaration(node.parent) || isClassDeclaration(node.parent))) {
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_function_method_or_class, tokenToString(modifier.kind));
}
break;
case SyntaxKind.OverrideKeyword:
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@
"category": "Error",
"code": 1276
},
"'{0}' modifier can only appear on a type parameter of a function or constructor": {
"'{0}' modifier can only appear on a type parameter of a function, method or class": {
"category": "Error",
"code": 1277
},
Expand Down