francescov1 / mongoose-tsgen

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

Using the code from the given example results in "Type instantiation is excessively deep and possibly infinite" error #95

Closed jainil closed 2 years ago

jainil commented 2 years ago

I created a starter typescript project and added the example file from the readme to test this out. However I am getting the following error for UserSchema:

Type instantiation is excessively deep and possibly infinite. ts(2589)

Is this an issue with the lib or my config?

My tsconfig:

{
  "compilerOptions": {
    "outDir": "dist",
    "baseUrl": ".",
    "declaration": true,
    "module": "commonjs",
    "target": "es6",
    "noEmitOnError": true,
    "sourceMap": true,
    "moduleResolution": "node",
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "strict": true
  },
  "include": [
    "src"
  ],
  "exclude": [
    "node_modules",
    "dist"
  ]
}
jainil commented 2 years ago

Found a corresponding report on mongoose repo regarding this issue: https://github.com/Automattic/mongoose/issues/11787

For now fixing mongoose version to 6.3.1 solves the problem for me.

Closing since this is an upstream issue.

francescov1 commented 2 years ago

Thanks @jainil. Ill keep an eye on the upstream issue and make any required updates if needed.

francescov1 commented 1 year ago

@jainil Note that this issue has been resolved in newer Mongoose versions, so if you want to upgrade your Mongoose version you can do so (must be 6.4.1 or higher)