Skip to content

TypeScript Regression: deleteMany, deleteOne, replaceOne, updateMany, updateOne no longer support arbitrary options #14341

@juona

Description

@juona

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Mongoose version

8.1.1

Node.js version

18.18.2

MongoDB server version

5

Typescript version (if applicable)

4.8.3

Description

Some of my custom plugins rely on parameters being passed to operations, like so:

await MyModel.updateMany(
    {},
    {
        $set: {
            a: "a"
        }
    },
    {
        disableAutoSession: true // <--- compilation error here
    }
);

After migrating from 7.6.7 to 8.1.1 this no longer compiles. This is true for deleteMany, deleteOne, replaceOne, updateMany and updateOne. Other methods, e.g. findOneAndDelete still accept arbitrary options:

await MyModel.findOneAndDelete(
    {},
    {
        disableAutoSession: true // <--- this is fine
    }
);

The corresponding Document methods (deleteOne, replaceOne, updateOne) accept arbitrary parameters as well.

Steps to Reproduce

See description.

Expected Behavior

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    typescriptTypes or Types-test related issue / Pull Request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions