From a2a303f5271d172cf77d5b723dca2d8a00d27877 Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Tue, 10 Sep 2024 11:25:40 +0200 Subject: [PATCH] docs(HighlightInlintType): hide `undefined` in types --- .../content/HighlightInlineType.vue | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/docs/app/components/content/HighlightInlineType.vue b/docs/app/components/content/HighlightInlineType.vue index cff1b634..1d833cb5 100644 --- a/docs/app/components/content/HighlightInlineType.vue +++ b/docs/app/components/content/HighlightInlineType.vue @@ -4,17 +4,24 @@ const props = defineProps<{ }>() const type = computed(() => { - if (props.type.includes(', "as" | "asChild" | "forceMount">')) { - return props.type.replace(`, "as" | "asChild" | "forceMount">`, ``).replace('Omit<', '') + let type = props.type + if (type.includes(', "as" | "asChild" | "forceMount">')) { + type = type.replace(`, "as" | "asChild" | "forceMount">`, ``).replace('Omit<', '') } - if (props.type.includes(', "as" | "asChild">')) { - return props.type.replace(', "as" | "asChild">', '').replace('Omit<', '') + if (type.includes(', "as" | "asChild">')) { + type = type.replace(', "as" | "asChild">', '').replace('Omit<', '') + } + if (type.startsWith('undefined |')) { + type = type.replace('undefined |', '') + } + if (type.endsWith('| undefined')) { + type = type.replace('| undefined', '') } - return props.type + return type }) -const { data: ast } = await useAsyncData(`hightlight-inline-code-${props.type}`, () => parseMarkdown(`\`${type.value}\`{lang="ts-type"}`)) +const { data: ast } = await useAsyncData(`hightlight-inline-code-${type.value}`, () => parseMarkdown(`\`${type.value}\`{lang="ts-type"}`))