MCPcopy Index your code
hub / github.com/nodejs/node / checkGrammarMethod

Function checkGrammarMethod

test/fixtures/snapshot/typescript.js:88628–88674  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

88626 }
88627 }
88628 function checkGrammarMethod(node) {
88629 if (checkGrammarFunctionLikeDeclaration(node)) {
88630 return true;
88631 }
88632 if (node.kind === 169 /* SyntaxKind.MethodDeclaration */) {
88633 if (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) {
88634 // We only disallow modifier on a method declaration if it is a property of object-literal-expression
88635 if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 131 /* SyntaxKind.AsyncKeyword */)) {
88636 return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here);
88637 }
88638 else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) {
88639 return true;
88640 }
88641 else if (checkGrammarForInvalidExclamationToken(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context)) {
88642 return true;
88643 }
88644 else if (node.body === undefined) {
88645 return grammarErrorAtPos(node, node.end - 1, ";".length, ts.Diagnostics._0_expected, "{");
88646 }
88647 }
88648 if (checkGrammarForGenerator(node)) {
88649 return true;
88650 }
88651 }
88652 if (ts.isClassLike(node.parent)) {
88653 if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(node.name)) {
88654 return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher);
88655 }
88656 // Technically, computed properties in ambient contexts is disallowed
88657 // for property declarations and accessors too, not just methods.
88658 // However, property declarations disallow computed names in general,
88659 // and accessors are not allowed in ambient contexts in general,
88660 // so this error only really matters for methods.
88661 if (node.flags & 16777216 /* NodeFlags.Ambient */) {
88662 return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type);
88663 }
88664 else if (node.kind === 169 /* SyntaxKind.MethodDeclaration */ && !node.body) {
88665 return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type);
88666 }
88667 }
88668 else if (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) {
88669 return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type);
88670 }
88671 else if (node.parent.kind === 182 /* SyntaxKind.TypeLiteral */) {
88672 return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type);
88673 }
88674 }
88675 function checkGrammarBreakOrContinueStatement(node) {
88676 var current = node;
88677 while (current) {

Callers 2

checkObjectLiteralMethodFunction · 0.85
checkMethodDeclarationFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…