How can I document React component props so that the comments appear in the documentation for the component itself?
Here’s an example. Suppose you have this component:
type TableProps = {
/** An array of objects with name and key properties */
columns: Column[];
/** An array of row objects */
rows: Row[];
};
/** A table component */
const Table = ({
columns,
rows
}: TableProps) => {
When a developer looks up this component’s documentation, they just see A table component
. It would be so awesome if they instead saw something like this:
A table component
Props:
* columns: Column[] - An array of objects with name and key properties
* rows: Row[] - An array of row objects
As far as I know this isn’t possible within Typescript.
We could write out all the comments on the props again inside a comment on the component, but that feels like busy work that leads to out-of-date documentation.
Do any of the major IDEs have a plugin that solves this problem?