typescriptnestjssequelize-typescript

NestJS Sequelize - fields, which can be null are not recognized as possible null in rest of code


I am starting to work with NestJS and PostgreSQL databases. I created a model called User. In this model is a column named verifiedAt. It looks like:

@Column({
    type: DataType.DATE,
    allowNull: true,
})
verifiedAt: Date | null;

A value of the column can be null. But when I reference this property from another place in my code, the IDE doesn't recognize that it may be null. Shows only the Date type.

Type

Why it is like this? What should I change to fix this?


Solution

  • I found a resolution. In tsconfig.json the strictNullChecks flag must be set to true.