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

Function moduleMembers

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

Source from the content-addressed store, hash-verified

437}
438
439const moduleMembers = (
440 node: ts.ModuleDeclaration,
441 context: SerializationContext
442): ReadonlyArray<DeclarationModel> => {
443 let body = node.body
444 while (body !== undefined && ts.isModuleDeclaration(body)) {
445 body = body.body
446 }
447 if (body === undefined || !ts.isModuleBlock(body)) {
448 return []
449 }
450 return body.statements.flatMap((statement) => {
451 if (
452 ts.isFunctionDeclaration(statement) || ts.isInterfaceDeclaration(statement) ||
453 ts.isTypeAliasDeclaration(statement) || ts.isClassDeclaration(statement) ||
454 ts.isEnumDeclaration(statement) || ts.isModuleDeclaration(statement) ||
455 ts.isVariableStatement(statement)
456 ) {
457 if (ts.isVariableStatement(statement)) {
458 return statement.declarationList.declarations.map((declaration) => serializeDeclaration(declaration, context))
459 }
460 return [serializeDeclaration(statement, context)]
461 }
462 if (ts.isExportDeclaration(statement) || ts.isImportDeclaration(statement)) {
463 return []
464 }
465 throw new Error(`Unsupported public namespace statement: ${ts.SyntaxKind[statement.kind]}`)
466 }).sort((left, right) => `${left.kind}:${left.name}`.localeCompare(`${right.kind}:${right.name}`))
467}
468
469const serializeDeclaration = (node: ts.Declaration, context: SerializationContext): DeclarationModel => {
470 if (ts.isFunctionDeclaration(node)) {

Callers 1

serializeDeclarationFunction · 0.85

Calls 2

serializeDeclarationFunction · 0.85
mapMethod · 0.45

Tested by

no test coverage detected