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
But when I pass those options as a spread variable, I get this :
// Meant to be reused across multiple calls of .findAll, .findOne, .findByPkconstQUERY={where: {modelId: id},attributes: {exclude: ['created_at','updated_at','context']},include: [/* Multiple includes */],order: [['COL_X','DESC'],[sequelize.col('`INCLUDE_1`.`order`'),'ASC'],[sequelize.col('`INCLUDE_2`.`order`'),'ASC'],[sequelize.col('`INCLUDE_3`.`order`'),'ASC']],subQuery: false,};returnMyModel.findAll(QUERY);
Argument of type '{ attributes: { exclude: string[]; }; include: ({ model: typeof INCLUDE_MODEL_1; as: string; required: boolean; attributes: string[]; through: { attributes: any[]; }; } | { model: typeof INCLUDE_MODEL_2; as: string; required: boolean; attributes: string[]; through: { ...; }; } | { ...; } | { ...; })[]; ord...' is not assignable to parameter of type 'FindOptions<MyModelAttributes>'.
Types of property 'order' are incompatible.
Type '(string | Col)[][]' is not assignable to type 'Order'.
Type '(string | Col)[][]' is not assignable to type 'OrderItem[]'.
Type '(string | Col)[]' is not assignable to type 'OrderItem'.
Type '(string | Col)[]' is not assignable to type '[OrderItemAssociation, OrderItemAssociation, OrderItemAssociation, OrderItemAssociation, OrderItemColumn, string]'.
Target requires 6 element(s) but source may have fewer.
For now I have to add @ts-ignore above the function call to silent those errors, and the queries work perfectly as they match the sequelize expected format
Expected behavior
Have the typing work the same way of the options are passed directly or through a variable
The text was updated successfully, but these errors were encountered:
Issue
When passing
FindOptions
through a variable instead of defining them in the function call, typescript throws an error.Versions
6.32.1
2.1.5
4.9.5
Issue type
Actual behavior
When passing
FindOptions
directly tofindAll
,findByPk
,fondOne
, ..., everything works as expected:But when I pass those options as a spread variable, I get this :
For now I have to add
@ts-ignore
above the function call to silent those errors, and the queries work perfectly as they match the sequelize expected formatExpected behavior
Have the typing work the same way of the options are passed directly or through a variable
The text was updated successfully, but these errors were encountered: