typegoose使用报错
koa项目引入typegoose后运行报错:
具体报错内容:
6:54:09 PM - File change detected. Starting incremental compilation...
node_modules/@typegoose/typegoose/lib/hooks.d.ts(8,41): error TS2707: Generic type 'Query<ResultType, DocType, THelpers, RawDocType>' requires between 2 and 4 type arguments.
6:54:09 PM - Found 1 error. Watching for file changes.
泛型类型“Query<ResultType, DocType, THelpers, RawDocType>”需要介于 2 和 4 类型参数之间。
model.js:
import { getModelForClass, prop } from '@typegoose/typegoose'
class StoryClass {
@prop()
public id?: string;
@prop()
public name?: string;
}
const StoryModel = getModelForClass(StoryClass)
export default StoryModel
依赖版本:
"dependencies": {
"@typegoose/typegoose": "^7.6.1",
"axios": "^0.21.1",
"dayjs": "^1.10.5",
"koa": "^2.13.1",
"koa-router": "^10.0.0",
"mongoose": "^5.13.1"
},
"devDependencies": {
"@types/koa": "^2.13.1",
"@types/koa-router": "^7.4.1",
"@types/mongoose": "^5.11.97",
"@types/node": "^14.14.37",
"ts-node": "^9.1.1",
"tsc-watch": "^4.4.0",
"typescript": "^4.2.4"
},
有大佬帮忙看看什么问题吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
应该是你安装的@types/mongoose和mongoose自带的.d.ts文件有冲突,mongoose在5.10.18开始自带.d.ts文件了。