createTime

TypeScript 报错:Type '({ filename: string; createTime: string; filePath: string; fileId: number; } | undefined)[]' is not assignable to type 'PiFile[]'.

问题: 因为TypeScript不支持直接给一个接口类型的变量 赋一个未知的值。 如 const a:A = { name:'s' }; 你需要给这样的对象或数组值使用as 指定一个类型。 正确写法: const a:A = { name:'s' } as A; 数组写法一样: const a:A[ ......
string 39 TypeScript createTime assignable
共2篇  :1/1页 首页上一页1下一页尾页