In the code below I get the following error: Property 'latlng' of type 'LatLng[]' is not assignable to string index type 'string[]'.ts(2411). Am I not allowed to have a string index in Typescript? How can I fix this?
interface LatLng {
lat: number;
long: number;
}
export interface Country {
[countryName: string]: Capital[];
latlng: LatLng[];
}
type Capital = string;
This is how I am setting the array from the API
const randomCountries = randomCountriesFull.map((country) => {
return {
[country.name.common]: country.capital,
latlng: country.latlng,
};
});