6

Given this

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

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


function Index({ savedLocationsWeather, favoriteLocationWeather }: IndexProp)

What should the documentation look like?

My first approach was:

/**
 * 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}
 */

But:

  1. I'm not sure if that's the correct way to specify the Array type of savedLocationsWeather as in

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

  2. I'm also not sure it's correct to specify LocationWeather as a jsdoc type, as in

    * @param {Locationweather} props.favoriteLocationWeather Weather details of favorite location

  3. Is there even such a thing as a TSX.Element type, as in

    * @return {TSX.Element}

Finally, should I define PropTypes as done here

Dozie
  • 103
  • 11

0 Answers0