Flow version: 0.126.1 (but older versions are also affected)
The expected behavior is that Flow would throw an error on the last line:
type User = $Shape<{|
+name: string,
+email: string,
|}>;
const user: User = {
...null,
};
user.name.toLowerCase();
// ^^^^^^^^^^^
// Would expect error here, since
// `name` can still be undefined
It's incorrectly accepted as a valid program, reporting no errors. See Try-Flow.
It may be worth nothing that if you avoid the use of $Shape in the User definition, this bug _is_ getting caught correctly. See Try-Flow.
See #7316, #7730, #7566, #5702, #6039, #6796.
That's how $Shape works, it's an unsound escape hatch. Use
type Partial<T> = $Rest<T, {...}>
instead. Try Flow.
please close your question so we can center in the unsewered ones
Most helpful comment
See #7316, #7730, #7566, #5702, #6039, #6796.
That's how
$Shapeworks, it's an unsound escape hatch. Useinstead. Try Flow.