This is the code snippet I am using as a reference:
const MyArray = [
{ name: "Alice", age: 15 },
{ name: "Bob", age: 23 },
{ name: "Eve", age: 38 },
];
type Name = typeof MyArray[string]["name"]; //throws error as Type '{ name: string; age: number; }[]' has no matching index signature for type 'string'
type Age = typeof MyArray[number]["age"] //no error
I've noticed that I can easily access the age property, but encountering an error when trying to access the name in a similar manner. Can someone explain why this error occurs? Any help would be greatly appreciated!
Thank you in advance.