docs-util: collapse types in references (#11888)

* docs-util: collapse types in references

* improve for arrays
This commit is contained in:
Shahed Nasser
2025-03-18 16:49:34 +02:00
committed by GitHub
parent ac24749bd3
commit eb2aa8da3c
@@ -108,14 +108,27 @@ export function getReflectionTypeParameters({
return return
} }
const reflectionTypeParameters = getReflectionTypeParameters({
reflectionType: reflectionTypeArg,
project,
level: level + 1,
maxLevel,
isReturn: false,
})
if (
typeArgs.length === 1 &&
reflectionTypeArg.type === "reference" &&
reflectionTypeParameters.length === 1
) {
componentItem[parentKey - 1].children?.push(
...(reflectionTypeParameters[0].children || [])
)
return
}
componentItem[parentKey - 1].children?.push( componentItem[parentKey - 1].children?.push(
...getReflectionTypeParameters({ ...reflectionTypeParameters
reflectionType: reflectionTypeArg,
project,
level: level + 1,
maxLevel,
isReturn: false,
})
) )
}) })
} }
@@ -172,11 +185,20 @@ export function getReflectionTypeParameters({
const elementTypeItem = getReflectionTypeParameters({ const elementTypeItem = getReflectionTypeParameters({
reflectionType: reflectionType.elementType, reflectionType: reflectionType.elementType,
project, project,
level: level + 1, level,
maxLevel, maxLevel,
isReturn: false, isReturn: false,
}) })
componentItem[parentKey - 1].children?.push(...elementTypeItem) if (
reflectionType.elementType.type === "reference" &&
elementTypeItem.length === 1
) {
componentItem[parentKey - 1].children?.push(
...(elementTypeItem[0].children || [])
)
} else {
componentItem[parentKey - 1].children?.push(...elementTypeItem)
}
} }
} else if (reflectionType.type === "tuple") { } else if (reflectionType.type === "tuple") {
let pushTo: Parameter[] = [] let pushTo: Parameter[] = []