(pos int, jsdoc jsdocScannerInfo, modifiers *ast.ModifierList)
| 3575 | } |
| 3576 | |
| 3577 | func (p *Parser) parsePropertyOrMethodSignature(pos int, jsdoc jsdocScannerInfo, modifiers *ast.ModifierList) *ast.Node { |
| 3578 | name := p.parsePropertyName() |
| 3579 | questionToken := p.parseOptionalToken(ast.KindQuestionToken) |
| 3580 | var result *ast.Node |
| 3581 | if p.token == ast.KindOpenParenToken || p.token == ast.KindLessThanToken { |
| 3582 | // Method signatures don't exist in expression contexts. So they have neither |
| 3583 | // [Yield] nor [Await] |
| 3584 | typeParameters := p.parseTypeParameters() |
| 3585 | parameters := p.parseParameters(ParseFlagsType) |
| 3586 | returnType := p.parseReturnType(ast.KindColonToken /*isType*/, true) |
| 3587 | result = p.factory.NewMethodSignatureDeclaration(modifiers, name, questionToken, typeParameters, parameters, returnType) |
| 3588 | } else { |
| 3589 | typeNode := p.parseTypeAnnotation() |
| 3590 | // Although type literal properties cannot not have initializers, we attempt |
| 3591 | // to parse an initializer so we can report in the checker that an interface |
| 3592 | // property or type literal property cannot have an initializer. |
| 3593 | var initializer *ast.Expression |
| 3594 | if p.token == ast.KindEqualsToken { |
| 3595 | initializer = p.parseInitializer() |
| 3596 | } |
| 3597 | result = p.factory.NewPropertySignatureDeclaration(modifiers, name, questionToken, typeNode, initializer) |
| 3598 | } |
| 3599 | p.parseTypeMemberSemicolon() |
| 3600 | p.withJSDoc(p.finishNode(result, pos), jsdoc) |
| 3601 | return result |
| 3602 | } |
| 3603 | |
| 3604 | func (p *Parser) parseTypeLiteral() *ast.Node { |
| 3605 | pos := p.nodePos() |
no test coverage detected