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

Function parseClassId

packages/babel-parser/src/parser/statement.ts:2193–2212  ·  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

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

Callers

nothing calls this directly

Calls 2

tokenIsIdentifierFunction · 0.90
parseIdentifierMethod · 0.80

Tested by

no test coverage detected