Closed
Description
TypeScript Version: master
Search Terms:
Code
declare const o: { x: 0 } | undefined;
if (o?.x === 0) {
o.x;
}
declare const a: [0] | undefined;
if (a?.[0] === 0) {
a[0];
}
Expected behavior:
pass
Actual behavior:
$ node built/local/tsc --noEmit --strict index.ts
index.ts:3:3 - error TS2532: Object is possibly 'undefined'.
3 o.x;
~
index.ts:7:3 - error TS2532: Object is possibly 'undefined'.
7 a[0];
~
Found 2 errors.
Playground Link:
Related Issues: