Hello, I want to translate our admin forest app to typescript, I followed the instructions in the documentation, everything is working fine but I get the following error
Model creation error: TypeError: Cannot read property 'companyIdKey' of undefined
Model creation error: TypeError: Cannot read property 'name' of undefined
Model creation error: TypeError: Cannot read property 'undefined' of undefined
Model creation error: TypeError: Cannot read property 'undefined' of undefined
Model creation error: TypeError: Cannot read property 'undefined' of undefined
Model creation error: TypeError: Cannot read property 'name' of undefined
It still seem that things works properly, but I am just a bit worried haha
Expected behavior
No error message
Actual behavior
Thing seem to work but I get the following error message
Failure Logs
Model creation error: TypeError: Cannot read property 'companyIdKey' of undefined
Context
Please provide any relevant information about your setup.
- “forest-express-sequelize”: “^6.0.0”,
- Express Version: “~4.16.3”
- Sequelize Version: “~5.15.1”,
- Database Dialect: Postgres
- Database Version: “~6.1.0”,
- Project Name: Toolt-mvp,
“typescript”: “^3.9.7”
exemple of one of my models
import {
Model, Sequelize, DataTypes
} from 'sequelize';
import { User } from './user';
export class Company extends Model {
public id!: number;
public name!: string;
public users!: User[];
public readonly created_at: Date;
public readonly updated_at: Date;
}
export default (sequelize: Sequelize): typeof Company => {
Company.init(
{
// uuid : { type: DataTypes.UUID, },
name : { type: DataTypes.STRING, },
created_at: {
type : 'TIMESTAMP',
defaultValue: 'now()',
},
updated_at: { type: DataTypes.DATE, },
}, {
tableName : 'company',
modelName : 'company',
underscored: true,
sequelize
}
);
Company.hasMany(User, {
foreignKey: {
name : 'companyIdKey',
field: 'company_id',
},
as: 'users',
});
return Company;
};