-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Empty object is valid for non exact type annotation #8430
Comments
This is just how unsealed objects work in Flow. |
@jcready How is this related to sealed/unsealed if the type is explicitly specified? Also if it would be unsealed the following would be allowed: const someObj: { id: number } = {};
someObj.foo = 'foo'; but it is not https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoAxnAdgZwC5g5wC2ApgPIBGAVgFxgDeYAlgCb1YCuxlpATmAC+YALyNBAblREyVagDoocOKLAByJXDUSgA |
Annotating the type of |
Thanks @dsainati1 this makes it clearer. (I still feel like it is not desired behavior) |
Agreed. We have wanted to get rid of unsealed objects for a while, the difficulty is devising a new way to support the existing pattern of building up an object over time. |
See #7424 |
Fixed if you enabled |
Flow version: 0.128.0
Expected behavior
Type error
Actual behavior
num here is undefined, and definitely not a number
https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoAxnAdgZwC5g5wC2ApgPIBGAVgFxgDeYAlgCb1YCuxlpATmAC+YALyNBAbgzZ8YLsQ7deAsUTJVqAOjYSgA
The text was updated successfully, but these errors were encountered: