MCPcopy Create free account
hub / github.com/Effect-TS/effect / moduleMembers

Function moduleMembers

packages/tools/api-diff/src/Snapshot.ts:452–480  ·  view source on GitHub ↗
(
  node: ts.ModuleDeclaration,
  context: SerializationContext
)

Source from the content-addressed store, hash-verified

450}
451
452const moduleMembers = (
453 node: ts.ModuleDeclaration,
454 context: SerializationContext
455): ReadonlyArray<DeclarationModel> => {
456 let body = node.body
457 while (body !== undefined && ts.isModuleDeclaration(body)) {
458 body = body.body
459 }
460 if (body === undefined || !ts.isModuleBlock(body)) {
461 return []
462 }
463 return body.statements.flatMap((statement) => {
464 if (
465 ts.isFunctionDeclaration(statement) || ts.isInterfaceDeclaration(statement) ||
466 ts.isTypeAliasDeclaration(statement) || ts.isClassDeclaration(statement) ||
467 ts.isEnumDeclaration(statement) || ts.isModuleDeclaration(statement) ||
468 ts.isVariableStatement(statement)
469 ) {
470 if (ts.isVariableStatement(statement)) {
471 return statement.declarationList.declarations.map((declaration) => serializeDeclaration(declaration, context))
472 }
473 return [serializeDeclaration(statement, context)]
474 }
475 if (ts.isExportDeclaration(statement) || ts.isImportDeclaration(statement)) {
476 return []
477 }
478 throw new Error(`Unsupported public namespace statement: ${ts.SyntaxKind[statement.kind]}`)
479 }).sort((left, right) => `${left.kind}:${left.name}`.localeCompare(`${right.kind}:${right.name}`))
480}
481
482const serializeDeclaration = (node: ts.Declaration, context: SerializationContext): DeclarationModel => {
483 if (ts.isFunctionDeclaration(node)) {

Callers 1

serializeDeclarationFunction · 0.85

Calls 2

serializeDeclarationFunction · 0.85
mapMethod · 0.45

Tested by

no test coverage detected