MCPcopy Create free account
hub / github.com/babel/babel / parseClassId

Function parseClassId

packages/babel-parser/src/parser/statement.ts:2196–2215  ·  view source on GitHub ↗
(
    node: Undone<N.Class | N.StructDeclaration>,
    isStatement: boolean,
    optionalId?: boolean | null,
    bindingType: BindingFlag = BindingFlag.TYPE_CLASS,
  )

Source from the content-addressed store, hash-verified

2194 }
2195
2196 parseClassId(
2197 node: Undone<N.Class | N.StructDeclaration>,
2198 isStatement: boolean,
2199 optionalId?: boolean | null,
2200 bindingType: BindingFlag = BindingFlag.TYPE_CLASS,
2201 ): void {
2202 if (tokenIsIdentifier(this.state.type)) {
2203 node.id = this.parseIdentifier();
2204 this.checkStrictBindReservedWord(node.id, bindingType);
2205 if (isStatement) {
2206 this.declareNameFromIdentifier(node.id, bindingType);
2207 }
2208 } else {
2209 if (optionalId || !isStatement) {
2210 node.id = null;
2211 } else {
2212 throw this.raise(Errors.MissingClassName, this.state.startLoc);
2213 }
2214 }
2215 }
2216
2217 // https://tc39.es/ecma262/#prod-ClassHeritage
2218 parseClassSuper(

Callers

nothing calls this directly

Calls 2

tokenIsIdentifierFunction · 0.90
parseIdentifierMethod · 0.80

Tested by

no test coverage detected