in following code with strictNullChecks
turned on I'm getting an error
Object is possibly 'undefined'.
class Smth {
private data: Array<{ value: number} | undefined> = [];
public doSmth(i: number) {
const data = this.data;
return data[i] && data[i].value === 0
// ^^^^^^^ Object is possibly 'undefined'.
}
}
I can't understand how it can be undefined after a check.
data[i]!.value === 0