When I try accessing a variable in an array using array assignment or lookup I get a typescript linting error saying that Object is possibly 'undefined'.ts(2532). I try checking that all of the variables in the operation are not undefined yet that does not work. Here is my current code which creates a clone of a 2d array and sets a specific value to true.
let start: [number, number] = [0,0];
const visited: boolean[][] = Array.from<boolean[], boolean[]>({ length: rows },
() => Array<boolean>(cols).fill(false));
visited[start[0]][start[1]] = true;
The error specifically underlines "visited[start[0]]". Furthermore, this error occurs when I access an array defined in my react state.