8000 `const` modifier on type parameters by ahejlsberg · Pull Request #51865 · microsoft/TypeScript · GitHub
[go: up one dir, main page]

Skip to content

const modifier on type parameters #51865

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Dec 16, 2022
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
0