is there a way to add TSDoc to Mapped Types?

249 views Asked by At

here's a simple repo : https://codesandbox.io/s/elastic-ellis-bzo8h8?file=/src/App.tsx

enter image description here

I want to see my props description like above picture.

type AnimalAttributes = "head" | "tail";
type Animal = {
  /** more than one head or tail is gross */
  [k in AnimalAttributes]: number;
};

const OneHeadCat = (props: Animal): React.ReactElement => {
  return <div {...props}>meow!</div>;
};

export default function App() {
  return (
    <div className="App">
      <h1>Hello CodeSandbox</h1>
      <OneHeadCat head={2} tail={1} />
    </div>
  );
}

But code like these... using mapped Types, tsdoc doesn't work as expected.

How can I solve this?

0

There are 0 answers