Open hikeeba opened 7 months ago
It may be that AccountSchemaB
would throw an error at compile time with the added bob
property, but for AccountSchemaA
this error shows up immediately in the editor.
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!