const user = await User.build<User>(
{
email: '[email protected]', // <--- it would be so cool if i can get intellisense on which fields are available here.
password: '123456',
todos: [{ title: 'Do home work!' }, { title: 'Watch TV!' }]
},
{
include: [Todo]
}
);
Hey @BruceHem, build can be called with a second generic:
````typescript
interface IUser {
email: string;
// ...
}
User.build
email: ''
})
````
Or if you only need auto completion and don't care about what's optional or required, you can use typescripts build in mapped type Partial. With this approach you don't need to define an additional interface:
typescript
User.build<User, Partial<User>>({
email: ''
})
The problem with this approach is, that you will get auto completion for all your members within User - Which means function members as well. Thats why build<User, User>(Notice: I removed Partial here) is not a good idea .
Hey man thanks, this lib is freaking awesome. Waiting to see it reached v1 soon.
@BruceHem thank you very much :)
Most helpful comment
Hey man thanks, this lib is freaking awesome. Waiting to see it reached v1 soon.