Open davidxiaolux opened 4 years ago
different where conditions for type(https://github.com/sequelize/sequelize/blob/v5.22.0/types/lib/model.d.ts#L371) should allow different schema, but it complains it should be the same across all where conditions,
Probably sequelize issue, but it seems compatibility issue for sequelize/sequelize-typescript
Versions
I'm submitting a ...
[x] bug report [ ] feature request
Actual behavior:
For decorator
scopes
, allwhere
conditions ininclude
array seem enforce the same schema somehow? https://github.com/davidxiaolux/sequelize-typescript-example/blob/master/lib/models/Person.ts#L23Expected behavior:
should be no issue for
include
array with different conditions inwhere
Steps to reproduce: just open file https://github.com/davidxiaolux/sequelize-typescript-example/blob/master/lib/models/Person.ts#L23 via editor, like VS Code, it will give error indication.
` {
Type '{ model: typeof Post; required: true; where: { isDeleted: false; postCode?: undefined; }; order: Col; separate?: undefined; }' is not assignable to type 'IncludeOptions'. Types of property 'where' are incompatible. Type '{ isDeleted: false; postCode?: undefined; }' is not assignable to type 'WhereAttributeHash | AndOperator | OrOperator | Literal | Where | undefined'. Type '{ isDeleted: false; postCode?: undefined; }' is not assignable to type 'WhereAttributeHash'. Property 'postCode' is incompatible with index signature. Type 'undefined' is not assignable to type 'string | number | boolean | WhereAttributeHash | AndOperator | OrOperator | Literal | Where | WhereOperators | ... 4 more ... | null'. Overload 2 of 2, '(scopes: ScopeTableOptions): Function', gave the following error. Argument of type '() => { resources: { where: { isDeleted: false; }; include: ({ model: typeof Post; required: true; where: { isDeleted: false; postCode?: undefined; }; order: Col; separate?: undefined; } | { model: typeof Address; required: true; separate: true; where: { ...; }; order?: undefined; })[]; }; }' is not assignable to parameter of type 'ScopeTableOptions'.\n Index signature is missing in type '() => { resources: { where: { isDeleted: false; }; include: ({ model: typeof Post; required: true; where: { isDeleted: false; postCode?: undefined; }; order: Col; separate?: undefined; } | { model: typeof Address; required: true; separate: true; where: { ...; }; order?: undefined; })[]; }; }'.", "source": "ts", "startLineNumber": 20, "startColumn": 2, "endLineNumber": 39, "endColumn": 2 }`
meaning
where
s inhttps://github.com/davidxiaolux/sequelize-typescript-example/blob/master/lib/models/Person.ts#L27 and
https://github.com/davidxiaolux/sequelize-typescript-example/blob/master/lib/models/Person.ts#L34 should follow the exact schema?