Property does not exist on type ''


I am getting data from an api and i have written it’s types like this

interface Daily {
  dt: number;
  sunrise: number;
  sunset: number;
  moonrise: number;
  moonset: number;
  moon_phase: number;
  temp: {day: number, eve: number, max: number, min: number, morn: number, night: number}[];
  feels_like: {day: number, night: number, eve: number, morn: number}[];
  pressure: number;
  humidity: number;
  dew_point: number;
  wind_speed: number;
  wind_deg: number;
  wind_gust: number;
  weather:  { id: number, main: string, description: string, icon:string }[];
  clouds: number;
  pop: number;
  uvi: number;

interface PropsType{
    lat: number;
    lon: number;
    timezone: string;
    timezone_offset: number;
    daily: Daily[];

Now when I try to access[0] it give me the error "Property weather’ does not exist on type ‘Daily[]’." I don’t understand why? How do i fix this?


daily is an array so you can’t access
Maybe you meant to daily[0].weather

Answered By – Amr Elmohamady

Answer Checked By – Mary Flores (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.