I am new to TypeScript. I have the following interface defined:
interface Cities {
names: ["New York", "Chicago", "Los Angeles"]
// rest of the parameters
}
Now I have a function which takes in a parameter city which should only be the ones defined in names:
const getPopulation = (name: Cities["names"]) => {
// return population of city 'name'
}
However, the above would/does not work since Cities["names"] is an array. I want to reference the array values (i.e. "New York" etc.). How would I be able to do this?