docs-util: fix hook input type showing as __type (#10905)

This commit is contained in:
Shahed Nasser
2025-01-10 10:25:17 +02:00
committed by GitHub
parent ff725090bb
commit a607b8e800
42 changed files with 139 additions and 160 deletions

View File

@@ -511,6 +511,7 @@ class WorkflowsPlugin {
if (parameter.type.name === "__object") {
parameter.type.name = "object"
parameter.type.qualifiedName = "object"
}
signatureReflection.parameters = []

View File

@@ -146,7 +146,9 @@ export function getType({ reflectionType, ...options }: TypeOptions): string {
})
}
return reflectionType ? escapeChars(reflectionType.toString()) : ""
return reflectionType
? escapeChars(normalizeTypeName(reflectionType.toString()))
: ""
}
export function getReflectionType({
@@ -324,20 +326,26 @@ export function getReferenceType({
const reflection: string[] = [wrappedInBackticks ? "`" : ""]
if (modelReflection?.url) {
const reflectionName = normalizeTypeName(modelReflection.name || "")
const reflectionUrl =
modelReflection.name === "__type" ? undefined : modelReflection.url
reflection.push(
shouldShowLink
? `[${modelReflection.name}](${
shouldShowLink && reflectionUrl
? `[${reflectionName}](${
getRelativeUrlMethod?.(modelReflection.url) || modelReflection.url
})`
: getFormattedStr(modelReflection.name, false, escape)
: getFormattedStr(reflectionName, false, escape)
)
} else {
const reflectionName = normalizeTypeName(model.name)
const reflectionUrl =
model.name === "__type" ? undefined : model.externalUrl
reflection.push(
shouldShowLink
shouldShowLink && reflectionUrl
? model.externalUrl
? `[${model.name}]( ${model.externalUrl} )`
: model.name
: getFormattedStr(model.name, false, escape)
? `[${reflectionName}](${model.externalUrl})`
: reflectionName
: getFormattedStr(reflectionName, false, escape)
)
}
if (model.typeArguments && model.typeArguments.length > 0) {
@@ -578,3 +586,11 @@ function getFormattedStr(
) {
return wrapBackticks ? `\`${str}\`` : escape ? escapeChars(str) : str
}
function normalizeTypeName(name: string) {
if (name !== "__type") {
return name
}
return "object"
}