docs-util: handle workflows with intersection hook types (#12099)

This commit is contained in:
Shahed Nasser
2025-04-07 14:00:08 +03:00
committed by GitHub
parent 5b5fea29c7
commit fde85888bd
3 changed files with 87 additions and 24 deletions
@@ -5,6 +5,39 @@ import {
Reflection,
} from "typedoc"
export function getHookChildren(
reflection?: DeclarationReflection
): DeclarationReflection[] {
const hookChildren: DeclarationReflection[] = []
if (!reflection) {
return hookChildren
}
const hookChildrenProperty = reflection.getChildByName("hooks")
if (!(hookChildrenProperty instanceof DeclarationReflection)) {
return hookChildren
}
switch (hookChildrenProperty.type?.type) {
case "reflection":
hookChildren.push(
...(hookChildrenProperty.type.declaration.children || [])
)
break
case "intersection":
hookChildrenProperty.type.types.forEach((type) => {
if (type.type !== "reflection") {
return
}
hookChildren.push(...(type.declaration.children || []))
})
break
}
return hookChildren
}
export function cleanUpHookInput(
parameters: ParameterReflection[]
): ParameterReflection[] {