小编Doz*_*zie的帖子

如何使用 Jsdocs 和 Typescript 记录 React 功能组件

鉴于这种

type LocationWeather = {
  name: string;
  temperature: number;
};

type IndexProp = {
  savedLocationsWeather: LocationWeather[];
  favoriteLocationWeather: LocationWeather;
};


function Index({ savedLocationsWeather, favoriteLocationWeather }: IndexProp)

Run Code Online (Sandbox Code Playgroud)

文档应该是什么样的?

我的第一个方法是:

/**
 * Home page displaying weather details of saved locations and favorite location
 * @param {object} props Component props
 * @param {LocationWeather[]} props.savedLocationsWeather Weather details of saved locations
 * @param {LocationWeather} props.favoriteLocationWeather Weather details of favorite location
 * @return {TSX.Element}
 */
Run Code Online (Sandbox Code Playgroud)

但:

  1. 我不确定这是否是指定 savingLocationsWeather 的数组类型的正确方法,如

    * @param {Array} props.savedLocationsWeather Weather details of saved …

document jsdoc typescript reactjs react-functional-component

7
推荐指数
0
解决办法
1476
查看次数