Typescript array typing

Hey I was wondering why typescript doesn't indicate that the
name
here is possibly undefined when the arr is empty?
type T = { name: string }[];

const arr: T = [];

const name = arr[0].name; // no ts error but it throws Cannot read properties of undefined
Was this page helpful?