Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unsealed objects #7424

Closed
vicapow opened this issue Feb 1, 2019 · 7 comments
Closed

Remove unsealed objects #7424

vicapow opened this issue Feb 1, 2019 · 7 comments

Comments

@vicapow
Copy link
Contributor

vicapow commented Feb 1, 2019

unsealed objects seem to be unintuitive to most users new to Flow. It also seems to be a common source of unsoundness in mature projects.

@goodmind
Copy link
Contributor

goodmind commented Feb 1, 2019

Probably as lint rule?

@TrySound
Copy link
Contributor

TrySound commented Feb 1, 2019

@vicapow Do you mean this? https://medium.com/flow-type/on-the-roadmap-exact-objects-by-default-16b72933c5cf

@vicapow
Copy link
Contributor Author

vicapow commented Feb 1, 2019

@TrySound I believe that's in relation to exact objects, not unsealed objects but maybe there's some implications with defaulting to exact objects on unsealed objects I'm not understanding.

@goodmind A flow lint rule would be great! But there's still the problem of having to do {...null} if you want to create an empty, but not unsealed object.

const a: { foo: string} = {}; // No error?!

@lukeapage
Copy link
Contributor

Wow finally I understand all the weird bugs!

If you were allowed to assign any property to inexact object, then reading it back would be any but you wouldn’t have to make an empty object be weird in its definition.. wouldn’t that still allow unsealed usage untyped but not lead to many problems for people trying to use flow?

@nifgraup
Copy link

{} could be an exact object in some contexts and unsealed in others:

// exact
const foo1: {| bar?: boolean |} = {};
foo1.bar = true;

// unsealed
const foo2 = {};
foo2.baz = 1;

@thecotne
Copy link
Contributor

thecotne commented Apr 8, 2020

this is very important as unsealed objects are common only in facebook code base and no one else is familiar with this concept specially those who want to have sound type system

@gkz
Copy link
Member

gkz commented Oct 25, 2022

See https://medium.com/flow-type/improved-handling-of-the-empty-object-in-flow-ead91887e40c

@gkz gkz closed this as completed Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants