// @flow

type X = {foo: number, ...};
type Y = {bar: X, baz: ?X, ...};

declare const x1: ?X;
declare const x2: X;

declare const y1: ?Y;
declare const y2: Y;

x1?.['foo'] as empty;
x2?.['foo'] as empty;

y1?.['bar']?.['foo'] as empty;
y2?.['bar']?.['foo'] as empty;
y1?.['baz']?.['foo'] as empty;
y2?.['baz']?.['foo'] as empty;

y1?.['bar']['foo'] as empty;
y2?.['bar']['foo'] as empty;
y1?.['baz']['foo'] as empty;
y2?.['baz']['foo'] as empty;

y1['bar']?.['foo'] as empty;
y2['bar']?.['foo'] as empty;
y1['baz']?.['foo'] as empty;
y2['baz']?.['foo'] as empty;

(y1?.['bar'])['foo'] as empty;
(y2?.['bar'])['foo'] as empty;
(y1?.['baz'])['foo'] as empty;
(y2?.['baz'])['foo'] as empty;
