MCPcopy Create free account
hub / github.com/microsoft/typescript-go / checkMethodDeclaration

Method checkMethodDeclaration

internal/checker/checker.go:2785–2804  ·  view source on GitHub ↗
(node *ast.Node)

Source from the content-addressed store, hash-verified

2783}
2784
2785func (c *Checker) checkMethodDeclaration(node *ast.Node) {
2786 // Grammar checking
2787 if !c.checkGrammarMethod(node) {
2788 c.checkGrammarComputedPropertyName(node.Name())
2789 if ast.IsMethodDeclaration(node) && node.AsMethodDeclaration().AsteriskToken != nil && ast.IsIdentifier(node.Name()) && node.Name().Text() == "constructor" {
2790 c.error(node.Name(), diagnostics.Class_constructor_may_not_be_a_generator)
2791 }
2792 }
2793 // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration
2794 c.checkFunctionOrMethodDeclaration(node)
2795 // method signatures already report "implementation not allowed in ambient context" elsewhere
2796 if ast.HasSyntacticModifier(node, ast.ModifierFlagsAbstract) && ast.IsMethodDeclaration(node) && node.Body() != nil {
2797 c.error(node, diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, scanner.DeclarationNameToString(node.Name()))
2798 }
2799 // Private named methods are only allowed in class declarations
2800 if ast.IsPrivateIdentifier(node.Name()) && ast.GetContainingClass(node) == nil {
2801 c.error(node, diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies)
2802 }
2803 c.setNodeLinksForPrivateIdentifierScope(node)
2804}
2805
2806func (c *Checker) checkClassStaticBlockDeclaration(node *ast.Node) {
2807 // Grammar checking

Callers 1

Calls 15

checkGrammarMethodMethod · 0.95
errorMethod · 0.95
IsMethodDeclarationFunction · 0.92
IsIdentifierFunction · 0.92
HasSyntacticModifierFunction · 0.92
DeclarationNameToStringFunction · 0.92
IsPrivateIdentifierFunction · 0.92
GetContainingClassFunction · 0.92
AsMethodDeclarationMethod · 0.80

Tested by

no test coverage detected