francescov1 / mongoose-tsgen

A plug-n-play Typescript generator for Mongoose.
105 stars 24 forks source link

Minimum mongoose version #94

Closed NelsonFrancisco closed 2 years ago

NelsonFrancisco commented 2 years ago

I have mongoose 5.9.26 with mongoose-tsgen 6.0.10 but they seem incompatible. Typescript version is "4.6.3"

I think I'm following the dependency guideline at https://github.com/francescov1/mongoose-tsgen#mongoose-version

It generates the output mongoose.gen.ts file just fine

But I get some typescript errors when I run tsc

Here they are

src/interfaces/mongoose.gen.ts:4834:16 - error TS2665: Invalid module name in augmentation. Module 'mongoose' resolves to an untyped module at '/home/aldrich/workspace/chaser/models/node_modules/mongoose/index.js', which cannot be augmented.

4834 declare module 'mongoose' {
                    ~~~~~~~~~~

src/interfaces/mongoose.gen.ts:4839:24 - error TS2304: Cannot find name 'Model'.

4839       model?: string | Model<any, THelpers>,
                            ~~~~~

src/interfaces/mongoose.gen.ts:4839:24 - error TS4075: Parameter 'model' of method from exported interface has or is using private name 'Model'.

4839       model?: string | Model<any, THelpers>,
                            ~~~~~

src/interfaces/mongoose.gen.ts:4853:23 - error TS2304: Cannot find name 'PopulateOptions'.

4853       options: Modify<PopulateOptions, { path: T }> | Array<PopulateOptions>,
                           ~~~~~~~~~~~~~~~

src/interfaces/mongoose.gen.ts:4853:23 - error TS4075: Parameter 'options' of method from exported interface has or is using private name 'PopulateOptions'.

4853       options: Modify<PopulateOptions, { path: T }> | Array<PopulateOptions>,
                           ~~~~~~~~~~~~~~~

src/interfaces/mongoose.gen.ts:4853:61 - error TS2304: Cannot find name 'PopulateOptions'.

4853       options: Modify<PopulateOptions, { path: T }> | Array<PopulateOptions>,
                                                                 ~~~~~~~~~~~~~~~

src/interfaces/mongoose.gen.ts:4853:61 - error TS4075: Parameter 'options' of method from exported interface has or is using private name 'PopulateOptions'.

4853       options: Modify<PopulateOptions, { path: T }> | Array<PopulateOptions>,
                                                                 ~~~~~~~~~~~~~~~

Found 7 errors in the same file, starting at: src/interfaces/mongoose.gen.ts

Here's my tsconfig.ts json:

{
  "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "rootDir": "./",
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "moduleResolution": "node",
    "outDir": "./dist",
    "baseUrl": "./",
    "declaration": true,
    "resolveJsonModule": true
  },
  "exclude": ["tests", "jest.config.js"]
}

So, I'm I doing something wrong?

francescov1 commented 2 years ago

Hmm older versions of Mongoose are not well tested anymore (there's simply too many combinations to keep up).

Couple things to verify/try:

NelsonFrancisco commented 2 years ago

Yeah.

Looks like version 5.9.X isn't compatible

Thanks

francescov1 commented 2 years ago

Good to know, sorry this wasnt more clear!