让我们说我有一个这样的课程:
import { Injectable } from '@nestjs/common';
import { IsString } from 'class-validator';
import { prop } from '@typegoose/typegoose';
@Injectable()
export class Human
{
@prop({ unique: true })
@IsString()
readonly name: string;
}
问题是:我可以导出此类,以便接收端在没有装饰器的情况下获取它,如下所示:
class Human
{
readonly name: string;
}
我想导出类(装饰器具有其他依赖项),以便导入该文件的文件不需要这些装饰器使用的依赖项,例如nestjs,class-validator和typegoose。
我试图不写出“只读名称:字符串;”不止一次。