I’m trying to create a function which is passed an array of numbers to use as accessors for a multidimensional array. Checking if(someArray[accessors[0]] === null || someArray[accessors[0]][accessors[1]] === null) return; gives me a null exception saying that someArray[accessors[0]] could be null, disallowing the null check from continuing so I get the same error when trying to access the array past the if. someArray is nullable at every level (Array<Array<number | null> | null>).
I’ve tried this in a simpler situation by creating a multidimensional array with a variable someInt = 0 and doing the same thing. With let someInt = 0, it gives the same error. With const someInt = 0, it compiles fine.
So you’d figure that changing the function parameter “accessors” to readonly would get rid of the error since it’s supposed to be the same as const. Changed it to readonly and the problem persists.
Am I doing something wrong here, or is there a problem with TypeScript’s strict nullable? For various reasons, disabling strict nullable isn’t an option.