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

View File

@@ -108,14 +108,27 @@ export function getReflectionTypeParameters({
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(
...getReflectionTypeParameters({
reflectionType: reflectionTypeArg,
project,
level: level + 1,
maxLevel,
isReturn: false,
})
...reflectionTypeParameters
)
})
}
@@ -172,11 +185,20 @@ export function getReflectionTypeParameters({
const elementTypeItem = getReflectionTypeParameters({
reflectionType: reflectionType.elementType,
project,
level: level + 1,
level,
maxLevel,
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") {
let pushTo: Parameter[] = []