TypeScript项目启动,报错,提示:
Property 'deployTime' is missing in type '{ id: any; name: string; no: string; }'.
原因:TS中有个类Device, 有个deployTime属性,类型是string。
export class Device { id: number; name: string; no: string; deployTime: string; }
不过数据库中,部分记录的deployTime字段是null
看来前端TS中,对于null并没有自动兼容。
解决的办法:把deployTime这个属性的数据类型改为首字母大写的 String,这样就能兼容值为null的情况。
deployTime: String;
重启node,问题解决。