Open zebkailash opened 3 years ago
Thanks a lot, guys, for this package! I have a similar error with offset property inside deep include. The following code worked before the project was typescripted. Please give me suggestions of how can I fix it?
package.json:
code:
let teamEvent = await TeamEventModel.findOne({
where: {url_code},
include: [{
Event: EventModel,
include: [{
Game: GameModel,
include: [{
model: PartModel,
order: [['order', 'ASC']],
limit: 1,
offset: 1,
}]
}]
}]
});
error:
TS2769: No overload matches this call.
Overload 1 of 2, '(this: ModelStatic<TeamEventModel>, options: NonNullFindOptions<any>): Promise<TeamEventModel>', gave the following error.
Type '{ model: typeof PartModel; order: [string, string][]; limit: number; offset: number; }' is not assignable to type 'Includeable'.
Object literal may only specify known properties, and 'offset' does not exist in type 'typeof Model | Association<Model<any, any>, Model<any, any>> | IncludeOptions | { all: true; nested?: true | undefined; }'.
Overload 2 of 2, '(this: ModelStatic<TeamEventModel>, options?: FindOptions<any> | undefined): Promise<TeamEventModel | null>', gave the following error.
Type '{ model: typeof PartModel; order: [string, string][]; limit: number; offset: number; }' is not assignable to type 'Includeable'.
Object literal may only specify known properties, and 'offset' does not exist in type 'typeof Model | Association<Model<any, any>, Model<any, any>> | IncludeOptions | { all: true; nested?: true | undefined; }'.
@ezalivadnyi Add @ts-ignore-next-line
before the offset it will execute the query properly. Typings are not updated for offset property in include query.
Hey, is it still the case with sequelize@6.4.0
and sequelize-typescript@2.0.0
? @zebkailash
I can confirm that this is a bug in Sequelize, not Sequelize-Typescript. I've reopened your issue @goalia
Versions
I'm submitting a ...
[ ] bug report [ ] feature request
Actual behavior:
It gives compilation error with message property does not exist on typeof Model | IncludedOptions etc
Expected behavior:
It should not give compilation error as query which is created works as expected.
Steps to reproduce:
Create 2 Models eg: Team, Player
Association Team hasMany Players.
Fetch Team and its players.
Related code:
Workaround Add
@ts-ignore-next-line
before the offset property.