based on @njzk2 comment showing the specific documentation, the noUncheckedIndexedAccess
flag tells the typescript compiler to define index access as potentially undefined.
tsconfig.json
{
"compilerOptions": {
"noUncheckedIndexedAccess": true
}
}