declare function keyMirror(o: O): $KeyMirror; var o = keyMirror({ FOO: null, BAR: null, }); o.FOO as 'FOO'; // ok o.FOO as 'BAR'; // error, 'FOO' incompatible with 'BAR' export type Props = Readonly<{ a?: string, b?: string, }>; type KeyMirroredProps = Readonly<$KeyMirror>; export type SpreadKeyMirroredProps = Readonly<{ ...$Exact, }>; // The following should be okay, since KeyMirroredProps should behave just like // `Readonly<$ObjMapi(K) => K>>` that preserves the optionality of the // properties. ({b: 'b'} as SpreadKeyMirroredProps); declare const badKeyMirror: $KeyMirror<1>; badKeyMirror.f; // error