In most guides, chats, tutorial etc... the recommended way to type Sequelize models is to use the following code:
export interface IUserInstance extends Sequelize.Instance<IUserAttributes>, IUserAttributes {
prototype: {
verifyPassword: (password: string) => boolean;
};
}
the key part here is Sequelize.Instance<, in Sequelize v5+ you see the error:
Namespace '".../node_modules/sequelize/types/index"' has no exported member 'Instance'.
I have looked around but have not come across solution.
** Looking at this guide, section "Usage of sequelize.define" http://docs.sequelizejs.com/manual/typescript
There does NOT seem to be a clear way of working with associations in using define and typescript.
Any help / advice would be appreciated.
References:
- https://github.com/DefinitelyTyped/DefinitelyTyped/issues/35013
- https://github.com/sequelize/sequelize/issues/9760#issuecomment-472905585
- https://vivacitylabs.com/setup-typescript-sequelize/
Regards, Emir