Using Sequelize.Instance with Sequelize v5 & Typescript Using Sequelize.Instance with Sequelize v5 & Typescript typescript typescript

Using Sequelize.Instance with Sequelize v5 & Typescript


I searched a lot for a solution to this problem, and got it working with the following:

import sequelizeInstance from '..';import { Model, DataTypes } from 'sequelize';const config = {  tableName: 'User',  sequelize: sequelizeInstance,};class User extends Model {  id!: number;  firstName!: string;  lastName!: string;  /* some other properties*/  verifyPassword: (password: string) => boolean;  public readonly createdAt!: Date;  public readonly updatedAt!: Date;}User.init(  {    id: {      primaryKey: true,      type: DataTypes.INTEGER,      autoIncrement: true,    },    firstName: {      type: DataTypes.STRING,    },    lastName: {      type: DataTypes.STRING,    }  },  config,);User.prototype.verifyPassword = function(password: string) {  /* code here ... */};export default User;