<TSDoc>
Component
The <TSDoc>
component from nextra/tsdoc
generates a properties table that
displays:
- Property name
- TypeScript type
- Property description - is parsed from TSDoc inline
description or the
@description
tag. You can use any Markdown/MDX syntax here. - Default value - are extracted from the
@default
or@defaultValue
tag. - Permalink - a
#
anchor link to the property row for easy reference.
Server Component Only – This cannot be used in a client
component.
Available from: Nextra 4.3 (alpha).
Dependency: Uses TypeScript Compiler API from
ts-morph
.
Props
Name | Type | Default |
---|---|---|
code | string TypeScript source code to be processed. | |
flattened | boolean Whether to flatten nested objects.
E.g. ⚠️ Warning
Requires | false |
exportName | string The name of the exported declaration. | "default" |
renderMarkdown | (description: string) => Promise<ReactNode> Override the function to render markdown into JSX nodes. | compileMdx |
typeLinkMap | Record<string, string> Type links map. | {} |
Example
import { unstable_TSDoc as TSDoc } from 'nextra/tsdoc'
<TSDoc
code={`
import type { unstable_TSDoc as TSDoc } from 'nextra/tsdoc'
type MyProps = React.ComponentProps<typeof TSDoc>
export default MyProps`}
/>
Overriding a type
Overridden type can be specified inside the @remarks
tag using backticks (`).
type Example = {
/**
* **Foo** description.
* @default "dimaMachina"
* @remarks `"not dimaMachina"`
*/
foo: string
}
This means that while the property foo
type is string
, an alternative type
annotation is described in @remarks
.
Name | Type | Default |
---|---|---|
foo | "not dimaMachina" Foo description. | "dimaMachina" |