mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-25 04:20:02 +00:00
TypeScript: Support showing optional properties on TypeTable
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
---
|
||||
'fumadocs-typescript': patch
|
||||
'fumadocs-ui': patch
|
||||
---
|
||||
|
||||
Support showing optional properties on TypeTable
|
||||
@@ -18,6 +18,7 @@ export interface DocEntry {
|
||||
description: string;
|
||||
type: string;
|
||||
tags: Record<string, string>;
|
||||
required: boolean;
|
||||
}
|
||||
|
||||
interface EntryContext {
|
||||
@@ -160,6 +161,7 @@ function getDocEntry(
|
||||
),
|
||||
tags,
|
||||
type: typeName,
|
||||
required: !prop.isOptional(),
|
||||
};
|
||||
|
||||
transform?.call(context, entry, subType, prop);
|
||||
|
||||
@@ -109,6 +109,7 @@ export async function AutoTypeTable({
|
||||
type: entry.type,
|
||||
description: await renderMarkdown(entry.description),
|
||||
default: entry.tags.default || entry.tags.defaultValue,
|
||||
required: entry.required,
|
||||
},
|
||||
] as const,
|
||||
);
|
||||
|
||||
@@ -36,6 +36,8 @@ interface ObjectType {
|
||||
*/
|
||||
typeDescriptionLink?: string;
|
||||
default?: string;
|
||||
|
||||
required?: boolean;
|
||||
}
|
||||
|
||||
const field = cva('inline-flex flex-row items-center gap-1');
|
||||
@@ -64,7 +66,10 @@ export function TypeTable({ type }: { type: Record<string, ObjectType> }) {
|
||||
<tr key={key}>
|
||||
<td>
|
||||
<div className={field()}>
|
||||
<code className={cn(code({ color: 'primary' }))}>{key}</code>
|
||||
<code className={cn(code({ color: 'primary' }))}>
|
||||
{key}
|
||||
{!value.required && '?'}
|
||||
</code>
|
||||
{value.description ? <Info>{value.description}</Info> : null}
|
||||
</div>
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user