【发布时间】:2022-01-12 14:00:28
【问题描述】:
我有一个带有打字稿的用户模式,下面是我的界面
interface IUser{
name: string;
email: string;
password: string;
isAdmin: boolean;
}
下面是用户架构
const UserSchema = new Schema<IUser>(
{
name: {
type: String,
required: true,
},
email: {
type: String,
required: true,
unique: true,
validate: [validator.isEmail, "Please provide a valid email"],
},
password: {
type: String,
required: true,
minlength: 8,
},
isAdmin: {
type: Boolean,
required: true,
default: false,
},
},
{
timestamps: true,
}
);
const UserModel = model("User", UserSchema);
module.exports = UserModel;
我收到 typescript 错误:无类型函数调用可能不接受用户模式上的类型参数,在 express 和 mongoose 中使用编辑器 Visual Studio。
【问题讨论】:
-
我认为是 stackoverflow.com/questions/48228735/… 的重复。
标签: typescript express mongoose types mongoose-schema