Skip to Content
🎉 Nextra 4.0 is released. dimaMachina is looking for a new job or consulting.

<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.
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

NameTypeDefault
codestring

TypeScript source code to be processed.

flattenedboolean

Whether to flatten nested objects. E.g. { foo: { bar: string } } will be represented as: { foo.bar: string }

⚠️
Warning

Requires exactOptionalPropertyTypes: true in tsconfig.json

false
exportNamestring

The name of the exported declaration.

"default"
renderMarkdown(description: string) => Promise<ReactNode>

Override the function to render markdown into JSX nodes.

compileMdx
typeLinkMapRecord<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.

NameTypeDefault
foo"not dimaMachina"

Foo description.

"dimaMachina"
Last updated on