给出这个
type LocationWeather = {
name: string;
temperature: number;
};
type IndexProp = {
savedLocationsWeather: LocationWeather[];
favoriteLocationWeather: LocationWeather;
};
function Index({ savedLocationsWeather, favoriteLocationWeather }: IndexProp)
文档应该是什么样的?
我的第一个方法是:
/**
* 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}
*/
但是:
我不确定这是否是指定保存的LocationsWeather的数组类型的正确方法,如
* @param {Array} props.savedLocationsWeather Weather details of saved locations
我也不确定将LocationWeather指定为jsdoc类型是正确的,
* @param {Locationweather} props.favoriteLocationWeather Weather details of favorite location
甚至还有TSX.Element类型的东西,例如
* @return {TSX.Element}
最后,我应该定义PropTypes as done here