flow / flow-bin

Binary wrapper for Flow - A static type checker for JavaScript
https://flow.org
Other
535 stars 47 forks source link

empty Object is inexact #167

Closed julesair closed 4 years ago

julesair commented 4 years ago

Since upgrading from flow version 0.110.1 we need to replace the definition of an empty object {} with { ...null }, wherever we use it in an exact object e.g. for conditionally spreading a value into that exact object like in this example:

    const value = 4;
    const exactSample: ExactObject = {
      name: 'test',
      ...(value ? { value } : { ...null })
    };

I could not find a documentation for this behavior, and spreading null here does not make sense to me. But it seems like flow interprets {} as an inexact empty Object: image

TrySound commented 4 years ago

Actually empty objects was always inexact. If you didn't get an error it was a bug.

julesair commented 4 years ago

That makes sense. Thank you for the reply.