I'm trying to apply the TSDoc standard for comments to a React project written in Typescript (with an eye towards generating documentation with Typedoc), but can't find any definitive answers for the preferred way to annotate a React props
object. I've got this so far, where MyProps
is an interface:
/**
* Description of my function component
* @param props - React props
*/
export default function MyComponent(props: MyProps) { ...
Is there a preferred method?
You want to document the props interface, and not the component itself. Which means this is the same as documenting fields of an interface.
When you hover over
foo=
on the last line, you should see the documentation.Playground example.