我试过了:
@Post()
async create(@Body() body: CreateStreamDto): Promise<typeof Stream> {
return { id: '12', connectionUrl: 'stuff' }
}
但它说:
ype '{ id: string; connectionUrl: string; }' is not assignable to type 'typeof Stream'.
Object literal may only specify known properties, and 'id' does not exist in type 'typeof Stream'.
最佳答案
如果您要返回模型的实例,则只需要 Promise<Stream>
。 typeof Stream
可能会返回 Object
或类似的东西,这就是您收到上述错误的原因。
关于typescript - 如何使用 Sequelize-Typescript 模型定义指定 NestJs Controller 的返回类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62048965/