Reputation: 3830
This is the error message I am getting after upgrading to V5 from V4.
I can comment out the unknown part from the lib, and everything else runs just fine.
node_modules/sequelize/types/lib/model.d.ts:108:29 - error TS1110: Type expected.
108 method: string | [string, ...unknown[]];
This is my typical model definition:
interface IAllergenExtend extends Model {
id?: number;
name: string;
description: string;
updatedAt?: string;
createdAt?: string;
}
type AllergenModel = typeof Model &
(new (values?: object, options?: BuildOptions) => IAllergenExtend) & {
associate: (model: IDB) => any;
};
const allergenFactory = (sequalize: Sequelize) => {
const Allergen = (<AllergenModel>sequalize.define('Allergen', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: DataTypes.INTEGER
},
name: {
allowNull: false,
type: DataTypes.TEXT
},
description: {
allowNull: false,
type: DataTypes.TEXT
}
})) as AllergenModel;
Allergen.associate = (model: IDB) => {
Allergen.belongsToMany(model.Dish, {
through: db.AllergenDish,
foreignKey: 'allergenId',
as: 'dishes'
});
};
return Allergen;
};
export { allergenFactory, AllergenModel };
Upvotes: 2
Views: 2500
Reputation: 247
I have Node 12.13.0 with TS Version 3.7.2 and i am receiving this error when using Sequelize 5.21.2
Upvotes: -1
Reputation: 56
Check you typescript version. I had to update to 4.27.34 to get past this problem.
Upvotes: 4