MCPcopy Index your code
hub / github.com/microsoft/typescript-go / parseFunctionOrConstructorType

Method parseFunctionOrConstructorType

internal/parser/parser.go:3782–3800  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3780}
3781
3782func (p *Parser) parseFunctionOrConstructorType() *ast.TypeNode {
3783 pos := p.nodePos()
3784 jsdoc := p.jsdocScannerInfo()
3785 modifiers := p.parseModifiersForConstructorType()
3786 isConstructorType := p.parseOptional(ast.KindNewKeyword)
3787 debug.Assert(modifiers == nil || isConstructorType, "Per isStartOfFunctionOrConstructorType, a function type cannot have modifiers.")
3788 typeParameters := p.parseTypeParameters()
3789 parameters := p.parseParameters(ParseFlagsType)
3790 returnType := p.parseReturnType(ast.KindEqualsGreaterThanToken, false /*isType*/)
3791 var result *ast.TypeNode
3792 if isConstructorType {
3793 result = p.factory.NewConstructorTypeNode(modifiers, typeParameters, parameters, returnType)
3794 } else {
3795 result = p.factory.NewFunctionTypeNode(typeParameters, parameters, returnType)
3796 }
3797 p.finishNode(result, pos)
3798 p.withJSDoc(result, jsdoc)
3799 return result
3800}
3801
3802func (p *Parser) parseModifiersForConstructorType() *ast.ModifierList {
3803 if p.token == ast.KindAbstractKeyword {

Callers 2

parseTypeMethod · 0.95

Calls 12

nodePosMethod · 0.95
jsdocScannerInfoMethod · 0.95
parseOptionalMethod · 0.95
parseTypeParametersMethod · 0.95
parseParametersMethod · 0.95
parseReturnTypeMethod · 0.95
finishNodeMethod · 0.95
withJSDocMethod · 0.95
AssertFunction · 0.92
NewFunctionTypeNodeMethod · 0.80

Tested by

no test coverage detected