You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on an application where all the BE types are compiled into Typescript for me. I would love to be able to enforce type-safety on the models in factory to some extent.
Hi, @kjrocker. This is a valid concern. I'm working on the updated version of this library that covers improves type-safety as well. I can't promise to implement this into the existing version due to the lack of availability. But I do hope to get the new version out sometime soon (~this year).
In the next version, I tended to give the Schema generic to the consumer to specify the model on the type level:
I'm working on an application where all the BE types are compiled into Typescript for me. I would love to be able to enforce type-safety on the models in
factory
to some extent.I've got the following code
Obviously because of the getters I can't just do
user: { .... } as User
I also tried defining
type Factory<T> = { [P in keyof T]-?: () => T[P] };
With that, I can do
user: { .... } as Factory<User>
, which works for simple fields, but breaks for anything usingprimaryKey
,manyOf
,oneOf
, etc.Any thoughts? I'd really just like to make sure I'm not missing keys when I define new models.
The text was updated successfully, but these errors were encountered: