【发布时间】:2023-04-10 18:40:02
【问题描述】:
我是 ts 新手
我的这段代码
import service from "feathers-mongoose";
app.use("/orders", service({
CustomerModel
}));
Typescript 抛出以下错误
类型参数 '{ CustomerModel: Model
; }' 不是 可分配给“部分”类型的参数。
对象字面量只能指定已知属性和“CustomerModel” 在“部分”类型中不存在。
我的客户模型如下所示
import mongoose from "mongoose";
const Schema = mongoose.Schema;
const customerSchema = new Schema(
{
firstName: { type: String, required: true },
lastName: { type: String, required: true },
email: { type: String, required: true },
},
{
timestamps: true,
}
);
const Model = mongoose.model("customers", customerSchema);
export default Model;
谁能给我解释一下Partial< MongooseServiceOptions>是什么意思
另外,我知道这可能是在 stackoverflow 上已经提出的问题之一,但我在谷歌上搜索了完全相同的短语,但我找不到任何东西。
【问题讨论】:
-
不是一个完整的答案,但您正在寻找的是 Generics。
标签: typescript mongoose feathersjs