Skip to content

Types break in semver patch change #14462

@Anonymous4078

Description

@Anonymous4078

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.2.3

Node.js version

20.11.1

MongoDB server version

5.x

Typescript version (if applicable)

5.4.3

Description

› yarn build
Error: src/listeners/message/messageBulkDelete.ts(28,49): error TS2769: No overload matches this call.
  Overload [1](https://github.com/Anonymous4078/suggester/actions/runs/8382964808/job/22957771088?pr=327#step:6:1) of [4](https://github.com/Anonymous4078/suggester/actions/runs/8382964808/job/22957771088?pr=327#step:6:5), '(filter?: FilterQuery<GuildConfig> | undefined, projection?: ProjectionType<GuildConfig> | null | undefined, options?: QueryOptions<...> | ... 1 more ... | undefined): Query<...>', gave the following error.
    Type 'string | null' is not assignable to type 'Condition<string> | undefined'.
      Type 'null' is not assignable to type 'Condition<string> | undefined'.
  Overload 2 of 4, '(filter?: FilterQuery<GuildConfig> | undefined, projection?: ProjectionType<GuildConfig> | null | undefined): Query<...>', gave the following error.
    Type 'string | null' is not assignable to type 'Condition<string> | undefined'.
  Overload 3 of 4, '(filter?: FilterQuery<GuildConfig> | undefined): Query<(Document<unknown, {}, GuildConfig> & GuildConfig & { _id: ObjectId; }) | null, Document<...> & ... 1 more ... & { ...; }, {}, GuildConfig, "findOne">', gave the following error.
    Type 'string | null' is not assignable to type 'Condition<string> | undefined'.
Error: src/listeners/message/messageBulkDelete.ts(32,1[5](https://github.com/Anonymous4078/suggester/actions/runs/8382964808/job/22957771088?pr=327#step:6:6)): error TS2322: Type 'string | null' is not assignable to type 'Condition<string> | undefined'.
Error: src/listeners/message/messageDelete.ts(21,45): error TS2769: No overload matches this call.
  Overload 1 of 4, '(filter?: FilterQuery<GuildConfig> | undefined, projection?: ProjectionType<GuildConfig> | null | undefined, options?: QueryOptions<...> | ... 1 more ... | undefined): Query<...>', gave the following error.
    Type 'string | null' is not assignable to type 'Condition<string> | undefined'.
  Overload 2 of 4, '(filter?: FilterQuery<GuildConfig> | undefined, projection?: ProjectionType<GuildConfig> | null | undefined): Query<...>', gave the following error.
    Type 'string | null' is not assignable to type 'Condition<string> | undefined'.
  Overload 3 of 4, '(filter?: FilterQuery<GuildConfig> | undefined): Query<(Document<unknown, {}, GuildConfig> & GuildConfig & { _id: ObjectId; }) | null, Document<...> & ... 1 more ... & { ...; }, {}, GuildConfig, "findOne">', gave the following error.
    Type 'string | null' is not assignable to type 'Condition<string> | undefined'.
Error: src/listeners/message/messageDelete.ts(25,[11](https://github.com/Anonymous4078/suggester/actions/runs/8382964808/job/22957771088?pr=327#step:6:12)): error TS2322: Type 'string | null' is not assignable to type 'Condition<string> | undefined'.
Error: Process completed with exit code 1.

My code used to work till v8.2.2 and types suddenly broke with 8.2.3

Steps to Reproduce

await collection.findOneAndUpdate(
            { guildId },
            {
              $pull: { suggestions: { messageId: message.id } },
            },
          );

Expected Behavior

The types shouldn't break in a semver patch change

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stalecan't reproduceMongoose devs have been unable to reproduce this issue. Close after 14 days of inactivity.typescriptTypes or Types-test related issue / Pull Request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions