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
Following methods do not accept an object with an association,
Model.build()
Model.create()
modelInstance.set()
Versions
sequelize: 6.21.2
sequelize-typescript: 2.1.3
typescript: 4.7.4
Issue type
bug report
feature request
Actual behavior
Getting the following compiler error,
TS2345: Argument of type '{ email: string; role: Role; memberProfile: { interests: string[]; }; firstName: string; lastName: string; }' is not assignable to parameter of type 'Optional<User, NullishPropertiesOf>'. Type '{ email: string; role: Role; memberProfile: { cohort: string; }; firstName: string; lastName: string; }' is not assignable to type 'Partial<Pick<User, NullishPropertiesOf>>'. Types of property 'memberProfile' are incompatible. Type '{ interests: string[]; }' is missing the following properties from type 'MemberProfile': userId, $add, and 35 more.
Expected behavior
Should be able to pass an object with an association. Would like the initial data object type to be similar to RecursivePartial<>, i.e. RecursiveNullishPropertiesOf<>
The problem is when you have an association in your interface. Simple data types work in my set up as well. And my model uses itself as an interface export class User extends Model<User> {
Issue
Following methods do not accept an object with an association,
Model.build()
Model.create()
modelInstance.set()
Versions
Issue type
Actual behavior
Getting the following compiler error,
TS2345: Argument of type '{ email: string; role: Role; memberProfile: { interests: string[]; }; firstName: string; lastName: string; }' is not assignable to parameter of type 'Optional<User, NullishPropertiesOf>'. Type '{ email: string; role: Role; memberProfile: { cohort: string; }; firstName: string; lastName: string; }' is not assignable to type 'Partial<Pick<User, NullishPropertiesOf>>'. Types of property 'memberProfile' are incompatible. Type '{ interests: string[]; }' is missing the following properties from type 'MemberProfile': userId, $add, and 35 more.
Expected behavior
Should be able to pass an object with an association. Would like the initial data object type to be similar to
RecursivePartial<>
, i.e.RecursiveNullishPropertiesOf<>
Steps to reproduce
Please use the code below to reproduce.
Related code
The text was updated successfully, but these errors were encountered: