我正在使用sequelize-typescript
,我的代码是:
import Promise from "bluebird";
import { IncomingCall } from '../models/IncomingCall';
export function incoming(requestBody: object): Promise<IncomingCall> {
return IncomingCall.create({
CallSid: requestBody.CallSid
});
}
但我得到的错误是:
[ts]
Type 'Bluebird<import("/src/models/IncomingCall").IncomingCall>' is not assignable to type 'Bluebird<import("/src/models/IncomingCall").IncomingCall>'. Two different types with this name exist, but they are unrelated.
Types of property 'then' are incompatible.
我的
IncomingCall
是:import { Model, Column, Table, DataType } from "sequelize-typescript";
@Table
export class IncomingCall extends Model<IncomingCall> {
@Column
CallSid: string;
@Column
AccountSid: string;
@Column(DataType.JSON)
rawData: string;
}
我怎样才能让它正常工作?
最佳答案
export class IncomingCall extends Model<IncomingCall>
将定义时不存在的类型分配给类型参数时似乎不正确。我想像export class IncomingCall extends Model<{ Callsid: string; AccountsId: string; rawData: string; }>
这样的更好,或者您可以在另一个界面中定义模型的形状。