nestjs/mongoose

Don't extend `MongooseModuleOptions` from `Record<string, any>`

Closed this issue · 4 comments

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

The definition is too broad, property definitions are ignored, IntelliSense is not working, and there are no property suggestions (other than those from Promise type):

image

Minimum reproduction code

https://tsplay.dev/wXv78m

Steps to reproduce

  1. Create an arbitrary *.ts file
  2. npm i @nestjs/mongoose
  3. import type { MongooseModuleOptions } from '@nestjs/mongoose/dist/interfaces/mongoose-options.interface'
  4. Define an object shaped as MongooseModuleOptions
  5. Inspect object typings, properties, IntelliSense etc.

Expected behavior

The definition is specific, property definitions are picked up, and IntelliSense is working:

image

Package version

9.2.2

mongoose version

No response

NestJS version

No response

Node.js version

18.15.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

This is specifically a typings issue. The only fix needed is to remove extends Record<string, any> from here:

https://github.com/nestjs/mongoose/blob/master/lib/interfaces/mongoose-options.interface.ts#L6

Would you like tor create a PR for this issue?

Sure, on it

PR ready 👆 (#1804), all checks have passed

Let's track this here #1804