import { Expose, plainToClass } from 'class-transformer';
class User {
@Expose() id: number;
@Expose() firstName: string;
@Expose() lastName: string;
}
const fromPlainUser = {
unkownProp: 'hello there',
firstName: 'Umed',
lastName: 'Khudoiberdiev',
};
这是class-transformer 文档中的演示。这是我的问题:不是User
无效的 Typescript 类,因为它没有任何属性或构造函数的初始化程序吗?其实我把这个demo复制到IDE后,马上就ts(2564): Property 'id' has no initializer and is not definitely assigned in the constructor
报错了