Automattic / mongoose

MongoDB object modeling designed to work in an asynchronous environment.
https://mongoosejs.com
MIT License
26.97k stars 3.84k forks source link

Show to fix: `Type 'T' does not satisfy the constraint 'Document '.` #9787

Closed gtsigner closed 3 years ago

gtsigner commented 3 years ago

Do you want to request a feature or report a bug? maybe it's a bug

What is the current behavior? i use mongoose with nestjs

If the current behavior is a bug, please provide the steps to reproduce.

{
    "compilerOptions": {
        "module": "commonjs",
        "declaration": true,
        "removeComments": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "esModuleInterop": true,
        "target": "es2017",
        "sourceMap": true,
        "outDir": "./dist",
        "baseUrl": "./",
        "incremental": true
    },
    "exclude": [
        "node_modules",
        "dist"
    ],
    "include": [
        "src/**/*"
    ]
}

i update mongoose to latest version 5.11.11 and then i got error

node_modules/@nestjs/mongoose/dist/factories/schema.factory.d.ts:4:76 - error TS2344: Type 'T' does not satisfy the constraint 'Document<any>'.
synsh commented 3 years ago

run npm remove @types/mongoose && npm update @nestjs/mongoose, this should solve the problem.

vkarpov15 commented 3 years ago

@godtoy can you please confirm whether @sahasayan 's fix works for you?

gtsigner commented 3 years ago

hey, thanks , it's works