Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong typing on $mergeObjects with an object #13060

Closed
2 tasks done
Naeoth opened this issue Feb 21, 2023 · 0 comments · Fixed by #13470
Closed
2 tasks done

Wrong typing on $mergeObjects with an object #13060

Naeoth opened this issue Feb 21, 2023 · 0 comments · Fixed by #13470
Labels
typescript Types or Types-test related issue / Pull Request
Milestone

Comments

@Naeoth
Copy link

Naeoth commented Feb 21, 2023

Prerequisites

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

Mongoose version

6.8.3

Node.js version

16.15.0

MongoDB server version

5.0

Typescript version (if applicable)

4.9.4

Description

In a $group step of an aggregation with an inner $mergeObjects, the plain object type is missing in ObjectExpression.

Maybe adding { [key: string]: AccumulatorOperator } is the solution?

Steps to Reproduce

import { Schema, model } from "mongoose"

const schema = new Schema({ status: String })
const documentModel = model("Document", schema)

documentModel.aggregate([{
  $group: {
    _id: "$_id",
    merged: {
      $mergeObjects: {
        status: "$status", // typing error here but valid as query
      },
    },
  },
}])

Expected Behavior

No typing error.

@vkarpov15 vkarpov15 added this to the 6.9.3 milestone Feb 21, 2023
@vkarpov15 vkarpov15 added the typescript Types or Types-test related issue / Pull Request label Feb 21, 2023
@vkarpov15 vkarpov15 modified the milestones: 6.9.3, TypeScript backlog Feb 21, 2023
@vkarpov15 vkarpov15 modified the milestones: TypeScript backlog, 7.2.3 May 24, 2023
vkarpov15 added a commit that referenced this issue Jun 7, 2023
types(aggregate): allow object syntax for `$mergeObjects`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typescript Types or Types-test related issue / Pull Request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants