Closed chanlito closed 5 years ago
export interface IModels {
Todo: Model<Todo, any>; // Why can't I just use typeof Todo here?
[x: string]: Model<any, any>;
}
// after sequelize initialize somewhere...
const models = sequelize.models as IModels;
Seems strange about that typings.
@RobinBuschmann I think this should be compatible with the way we define the models in sequelize-typescript.
You mean https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/sequelize/index.d.ts#L5755 , right?
Unfortunately this is not compatible with the way sequelize-typescript defines its Model
. So that sequelize.Model !== sequelize-typescript.Model
. For sequelize-typescript
it needs to look like:
interface ModelsHashInterface {
[name: string]: typeof Model;
}
Ahh, and some 🎉🎉🎉🎉🎉 for the 200th issue 😀
Wow 200 issues already, didn't noticed it til u mentioned. 😄 🤣
@RobinBuschmann how would I override the existing type definition? I'm not experienced in this area. Been googling several hours now.
Hmm, I see, overriding will not work. You will always get an TS2415:Class 'XXX' incorrectly extends base class 'YYY'. Types of property 'aaa' are incompatible. Type 'ccc' is not assignable to type 'bbb'.
, right?
I'm afraid that we need to do the same with Sequelize.d.ts
what we did with Model.d.ts
to achieve this. So rewriting the whole typings for the Sequelize class.
😩 Guess I'll have to wait for next beta release.
Fixed by 87cc694
Released with 1.0.0-alpha.X
Hello everyone, currently
sequelize
instance has thismodels
field which is of typeModelsHashInterface
.Is there a better way than using (sequelize.models as MyOwnDefinedTypes) ?