Flow version: v0.107
Not sure if I'm crazy, but some very basic type checking seems to be just broken? Given
type Record = {
foo: number,
bar: string
}
const x: Record = {};
Error indicating x is not of type Record
No errors!
If you make the object exact, it does correctly errors.
The same if you add a property to the empty object.
I think this is related to: https://github.com/facebook/flow/issues/2977
And the weird differences you get with empty objects.
{} is special in flow, it's an unsealed object. The easiest way to avoid this is to do something like { ...null } which will result in a regular empty object.
Wow, that really clashes with your expectations after hearing Flow is supposed to value "soundness".
Always appreciate the hard work of devs to provide the community things for free, but feels like this whole project would be better off managing your expectations on it a differently.
Going to close this since #7424 seems to track this.
:+1: on removing unsealed objects fwiw.
Most helpful comment
{}is special in flow, it's an unsealed object. The easiest way to avoid this is to do something like{ ...null }which will result in a regular empty object.