mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 04:43:37 -05:00
Address code review
This commit is contained in:
@@ -11444,19 +11444,17 @@ namespace ts {
|
||||
forEach(node.declarationList.declarations, checkSourceElement);
|
||||
}
|
||||
|
||||
function checkGrammarDisallowedModifiersOnMethodInObjectLiteralExpression(node: Node) {
|
||||
if (node.modifiers) {
|
||||
if (node.parent.kind === SyntaxKind.ObjectLiteralExpression){
|
||||
// If this method declaration is a property of object-literal-expression
|
||||
if (isAsyncFunctionLike(node)) {
|
||||
if (node.modifiers.length > 1) {
|
||||
return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here);
|
||||
}
|
||||
}
|
||||
else {
|
||||
function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node: Node) {
|
||||
// We only disallow modifier on a method declaration if it is a property of object-literal-expression
|
||||
if (node.modifiers && node.parent.kind === SyntaxKind.ObjectLiteralExpression){
|
||||
if (isAsyncFunctionLike(node)) {
|
||||
if (node.modifiers.length > 1) {
|
||||
return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15015,7 +15013,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function checkGrammarMethod(node: MethodDeclaration) {
|
||||
if (checkGrammarDisallowedModifiersOnMethodInObjectLiteralExpression(node) ||
|
||||
if (checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) ||
|
||||
checkGrammarFunctionLikeDeclaration(node) ||
|
||||
checkGrammarForGenerator(node)) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user