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

Method parseNameOfParameter

internal/parser/parser.go:3368–3384  ·  view source on GitHub ↗
(modifiers *ast.ModifierList)

Source from the content-addressed store, hash-verified

3366}
3367
3368func (p *Parser) parseNameOfParameter(modifiers *ast.ModifierList) *ast.Node {
3369 // FormalParameter [Yield,Await]:
3370 // BindingElement[?Yield,?Await]
3371 name := p.parseIdentifierOrPatternWithDiagnostic(diagnostics.Private_identifiers_cannot_be_used_as_parameters)
3372 if name.Loc.Len() == 0 && modifiers == nil && ast.IsModifierKind(p.token) {
3373 // in cases like
3374 // 'use strict'
3375 // function foo(static)
3376 // isParameter('static') == true, because of isModifier('static')
3377 // however 'static' is not a legal identifier in a strict mode.
3378 // so result of this function will be Parameter (flags = 0, name = missing, type = undefined, initializer = undefined)
3379 // and current token will not change => parsing of the enclosing parameter list will last till the end of time (or OOM)
3380 // to avoid this we'll advance cursor to the next token.
3381 p.nextToken()
3382 }
3383 return name
3384}
3385
3386func (p *Parser) parseReturnType(returnToken ast.Kind, isType bool) *ast.TypeNode {
3387 if p.shouldParseReturnType(returnToken, isType) {

Callers 1

parseParameterExMethod · 0.95

Calls 4

nextTokenMethod · 0.95
IsModifierKindFunction · 0.92
LenMethod · 0.65

Tested by

no test coverage detected