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

Method parseEnumMember

internal/parser/parser.go:2126–2134  ·  view source on GitHub ↗

In an ambient declaration, the grammar only allows integer literals as initializers. In a non-ambient declaration, the grammar allows uninitialized members only in a ConstantEnumMemberSection, which starts at the beginning of an enum declaration or any time an integer literal initializer is encounte

()

Source from the content-addressed store, hash-verified

2124// ConstantEnumMemberSection, which starts at the beginning of an enum declaration
2125// or any time an integer literal initializer is encountered.
2126func (p *Parser) parseEnumMember() *ast.Node {
2127 pos := p.nodePos()
2128 jsdoc := p.jsdocScannerInfo()
2129 name := p.parsePropertyName()
2130 initializer := doInContext(p, ast.NodeFlagsDisallowInContext, false, (*Parser).parseInitializer)
2131 result := p.finishNode(p.factory.NewEnumMember(name, initializer), pos)
2132 p.withJSDoc(result, jsdoc)
2133 return result
2134}
2135
2136func (p *Parser) parseEnumDeclaration(pos int, jsdoc jsdocScannerInfo, modifiers *ast.ModifierList) *ast.Node {
2137 saveHasAwaitIdentifier := p.statementHasAwaitIdentifier

Callers

nothing calls this directly

Calls 7

nodePosMethod · 0.95
jsdocScannerInfoMethod · 0.95
parsePropertyNameMethod · 0.95
finishNodeMethod · 0.95
withJSDocMethod · 0.95
doInContextFunction · 0.85
NewEnumMemberMethod · 0.80

Tested by

no test coverage detected