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
When using findOrBuild static method, the defaults property from the options object requires the parameters already stated in the where object, if they are set as not null and creation mandatory in the model definition.
Expected behavior
I should expect to let me use the function without specifying them in defaults clause, because it forces me to duplicate the parameters already found in the where clause, since the function works just as fine without specifying them. Anther thing is that I can't wrap them with CreationOptional, because then it wouldn't work correctly on create anymore.
Steps to reproduce
Define a Sequelize model
Use the findOrBuild static method with where object
Try to omit the where object properties from the defaults object
TS2322: Type { name: string; } is not assignable to type
Optional<InferCreationAttributes<MyModel, { omit: never; }>, NullishPropertiesOf<InferCreationAttributes<MyModel, { omit: never; }>>>
Property userId is missing in type { name: string; } but required in type
Omit<InferCreationAttributes<MyModel, { omit: never; }>, NullishPropertiesOf<InferCreationAttributes<MyModel, { omit: never; }>>>
my-model. model. ts(11, 11): userId is declared here.
model. d. ts(1004, 3): The expected type comes from property defaults which is declared here on type
FindOrBuildOptions<InferAttributes<MyModel, { omit: never; }>, Optional<InferCreationAttributes<MyModel, { omit: never; }>, NullishPropertiesOf<InferCreationAttributes<MyModel, { ...; }>>>>
The text was updated successfully, but these errors were encountered:
Issue
Versions
Issue type
Actual behavior
When using
findOrBuild
static method, thedefaults
property from theoptions
object requires the parameters already stated in thewhere
object, if they are set as not null and creation mandatory in the model definition.Expected behavior
I should expect to let me use the function without specifying them in
defaults
clause, because it forces me to duplicate the parameters already found in thewhere
clause, since the function works just as fine without specifying them. Anther thing is that I can't wrap them withCreationOptional
, because then it wouldn't work correctly oncreate
anymore.Steps to reproduce
findOrBuild
static method withwhere
objectwhere
object properties from thedefaults
objectRelated code
TS2322: Type { name: string; } is not assignable to type
Optional<InferCreationAttributes<MyModel, { omit: never; }>, NullishPropertiesOf<InferCreationAttributes<MyModel, { omit: never; }>>>
Property userId is missing in type { name: string; } but required in type
Omit<InferCreationAttributes<MyModel, { omit: never; }>, NullishPropertiesOf<InferCreationAttributes<MyModel, { omit: never; }>>>
my-model. model. ts(11, 11): userId is declared here.
model. d. ts(1004, 3): The expected type comes from property defaults which is declared here on type
FindOrBuildOptions<InferAttributes<MyModel, { omit: never; }>, Optional<InferCreationAttributes<MyModel, { omit: never; }>, NullishPropertiesOf<InferCreationAttributes<MyModel, { ...; }>>>>
The text was updated successfully, but these errors were encountered: