-
Notifications
You must be signed in to change notification settings - Fork 931
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
ObjectSchema type vs ObjectSchema class vs object+shape #2200
Comments
It may be that |
there is no difference in behavior, the types are just different on the class vs the factory function. In general the types are going to be less accurate if you use the schema class directly. There are a lot of generics meant to be used in particular ways on them. Prefer the factory functions unless you are comfortable with complex generics |
What is the difference, and intended use case, for each of these 3 things? The documentation on ObjectSchema is very limited, and only appears to refer to it as a type and not as a class.
For example, what is the different between
AccountSchemaA
andAccountSchemaB
in the code below?From what I can tell, adding an unexpected property to
AccountSchemaA
, like in the example below, gives an error, but this does not happen forAccountSchemaB
.The error is
Object literal may only specify known properties, and 'bob' does not exist in type 'Shape<Account, AnyObject>'.ts(2353)
.Any details on this would be super helpful to make sure we are using this as intended and understand the tradeoffs between the two.
Thanks!
The text was updated successfully, but these errors were encountered: