MCPcopy Create free account
hub / github.com/TanStack/query / basePagesOfType

Function basePagesOfType

scripts/generate-docs.ts:489–531  ·  view source on GitHub ↗
(
  outputDir: string,
  type: string,
  seen: Set<string>,
)

Source from the content-addressed store, hash-verified

487// member of an intersection (skipping object literals, which only add properties), and the first type
488// argument of a utility that isn't built from one itself, like `Omit<…>`. Returns nothing unless every part is found.
489async function basePagesOfType(
490 outputDir: string,
491 type: string,
492 seen: Set<string>,
493): Promise<Array<string>> {
494 const expression = splitTopLevel(type, ' = ')[0]!
495 .replace(/^[|&]\s*/, '')
496 .replace(/^\(\) => /, '')
497 .trim()
498 const members = splitTopLevel(expression, ' & ').filter(
499 (member) => member !== 'object' && !member.startsWith('{'),
500 )
501 if (members.length > 1) {
502 const pages: Array<string> = []
503 for (const member of members) {
504 const memberPages = await basePagesOfType(outputDir, member, seen)
505 if (!memberPages.length) {
506 return []
507 }
508 pages.push(...memberPages)
509 }
510 return [...new Set(pages)]
511 }
512 const reference = members[0]?.match(/^(\w+)(?:<([\s\S]*)>)?$/)
513 if (!reference) {
514 return []
515 }
516 const [, name, typeArguments] = reference
517 const [firstTypeArgument] = typeArguments
518 ? splitTopLevel(typeArguments, ',')
519 : []
520 const page = await typePage(outputDir, name!)
521 const pages =
522 page && !(await isWrapperAlias(outputDir, page))
523 ? await basePages(outputDir, page, seen)
524 : []
525 if (pages.length) {
526 return pages
527 }
528 return firstTypeArgument
529 ? basePagesOfType(outputDir, firstTypeArgument, seen)
530 : []
531}
532
533async function basePages(
534 outputDir: string,

Callers 2

basePagesFunction · 0.85
findBasePagesFunction · 0.85

Calls 4

splitTopLevelFunction · 0.85
typePageFunction · 0.85
isWrapperAliasFunction · 0.85
basePagesFunction · 0.85

Tested by

no test coverage detected