-
-
Notifications
You must be signed in to change notification settings - Fork 530
Open
Description
I'm generating models with these switches on --cp p --cf p --cm p.
After the models are initialized, while querying, sequelize produces the following error.
(sequelize) Warning: Model "UsersToRoles" is declaring public class fields for attribute(s): "IdUser", "IdRole", "RoleName"
The model file has the following data generated..
export interface UsersToRolesAttributes {
IdUser: number;
IdRole: number;
RoleName?: string;
}
export class UsersToRoles extends Model<UsersToRolesAttributes, UsersToRolesCreationAttributes> implements UsersToRolesAttributes {
IdUser!: number;
IdRole!: number;
RoleName?: string;
.
.
.
.
Bunch of other stuff
static initModel (sequelize: Sequelize.Sequelize): typeof UsersToRoles {
return UsersToRoles.init({
IdUser: {
type: DataTypes.INTEGER,
allowNull: false,
primaryKey: true,
references: {
model: "user",
key: "id_user"
},
field: "id_user"
},
.
.
.
.
}
As given here, If I add declare in front of the properties. The error goes away.
export class UsersToRoles extends Model<UsersToRolesAttributes, UsersToRolesCreationAttributes> implements UsersToRolesAttributes {
declare IdUser: number;
declare IdRole: number;
declare RoleName?: string;
Using sequelize@6.15.1 and sequelize-auto@0.8.8
This issue did not occur in older versions with the same schema.... I upgraded sequelize and sequelize auto and this issue showed up.
Any help would be appreciated.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels