Skip to content

Commit 8e15a42

Browse files
author
Yui T
committed
Address code review
1 parent cdc999a commit 8e15a42

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/compiler/checker.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11444,19 +11444,17 @@ namespace ts {
1144411444
forEach(node.declarationList.declarations, checkSourceElement);
1144511445
}
1144611446

11447-
function checkGrammarDisallowedModifiersOnMethodInObjectLiteralExpression(node: Node) {
11448-
if (node.modifiers) {
11449-
if (node.parent.kind === SyntaxKind.ObjectLiteralExpression){
11450-
// If this method declaration is a property of object-literal-expression
11451-
if (isAsyncFunctionLike(node)) {
11452-
if (node.modifiers.length > 1) {
11453-
return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here);
11454-
}
11455-
}
11456-
else {
11447+
function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node: Node) {
11448+
// We only disallow modifier on a method declaration if it is a property of object-literal-expression
11449+
if (node.modifiers && node.parent.kind === SyntaxKind.ObjectLiteralExpression){
11450+
if (isAsyncFunctionLike(node)) {
11451+
if (node.modifiers.length > 1) {
1145711452
return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here);
1145811453
}
1145911454
}
11455+
else {
11456+
return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here);
11457+
}
1146011458
}
1146111459
}
1146211460

@@ -15015,7 +15013,7 @@ namespace ts {
1501515013
}
1501615014

1501715015
function checkGrammarMethod(node: MethodDeclaration) {
15018-
if (checkGrammarDisallowedModifiersOnMethodInObjectLiteralExpression(node) ||
15016+
if (checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) ||
1501915017
checkGrammarFunctionLikeDeclaration(node) ||
1502015018
checkGrammarForGenerator(node)) {
1502115019
return true;

0 commit comments

Comments
 (0)