After upgrade to typescript 2.6.1 will get this error.
error TS2345: Argument of type ... is not assignable to parameter of type 'IFindOptions'. Types of property 'where' are incompatible.
Workaround: lock the typescript version to 2.5.3
Not sure if the issue similar to #106
@micksatana Thanks for reporting. Can you provide a find example where the error is thrown? Or does this happen with any passed option to where?
I've got this bug after upgrading the typescript 2.6.1 in findAll IFindOptions where
@RobinBuschmann
On Typescript 2.6.1
CalendarEvent.findOne<CalendarEvent>({
where: {
ce_id: req.params.ce_id,
ce_created_by: req.user.user_id,
ce_active: true,
ce_deleted: false
}
})
Will returns this error
error TS2345: Argument of type
'{
where: {
ce_id: any;
ce_created_by: any;
ce_active: boolean;
ce_deleted: boolean;
};
}'
is not assignable to parameter of type 'IFindOptions'.
Types of property 'where' are incompatible.
When I downgrade to 2.5.3, it will not cause error.
Also getting the same error, downgraded to typescript 2.5.2 since it was the last one working.
Some (not all) of these problems would be fixed if sequelize-typescript upgrades its embedded copy of @types/sequelize to version 4.0.78.
Also the cause (at least for my cases) was the use of a boolean in a WHERE clause. TypeScript 2.6 must be more picky about that.
I can concur. I use the @DefaultScope({where: {active: true}}) and get the same thing:
Argument of type '{ where: { active: boolean; }; }' is not assignable to parameter of type 'Function | IScopeFindOptions'.
Type '{ where: { active: boolean; }; }' is not assignable to type 'IScopeFindOptions'.
Types of property 'where' are incompatible.
Type '{ active: boolean; }' is not assignable to type 'string | WhereOptions
Type '{ active: boolean; }' is not assignable to type '(string | col | and | or)[]'.
Property 'length' is missing in type '{ active: boolean; }'. (2345)
Anyone here experienced this error with another type than boolean in the where object literal? The error is caused by the sequelize typings -
type boolean was missing in the WhereOptions (https://github.com/DefinitelyTyped/DefinitelyTyped/commit/8f53357a4cc054add2111f7c3a07a92541298b5c#diff-0e3744815a33a1dfe3285ef4f51888e9) The next beta release will include the latest sequelize typings.
Most helpful comment
Also the cause (at least for my cases) was the use of a
booleanin a WHERE clause. TypeScript 2.6 must be more picky about that.