<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
@descriptiontag. You can use any Markdown/MDX syntax here. - Default value - are extracted from the
@defaultor@defaultValuetag. - Permalink - a
#anchor link to the property row for easy reference.
Note
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 | stringTypeScript source code to be processed. | |
flattened | booleanWhether to flatten nested objects.
E.g. | false |
exportName | stringThe 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" |
Last updated on