-
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
Ways to seal objects, even at instantiation? #1164
Comments
I found a workaround that properly throws errors for extra properties: type GetTableParams = {
table: string,
optionalProperty?: number,
// Mark any other properties as invalid.
[key: string]: void
};
db.getTable = (params: GetTableParams): Promise<Array<Object>> {
...
}
// Throws 'string: This type is incompatible with void'
db.getTable({table: 'foo', anInvalidProperty: 'bar'}); |
Thanks for the workaround. Proper support within Flow for sealed object types would be a big win for flow IMO. |
Can close this now that we have |
Is there a difference between the built-in |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We use objects often as a way to pass many parameters to remoting functions.
We'd like to very strictly typecheck these objects, but it appears we're unable to properly seal the objects in the type definitions. For example, we want the following code to fail:
Is there a way to signify that an object type should have only the properties in the typedef and nothing more?
The text was updated successfully, but these errors were encountered: