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

Aggregation project stage doesn't accept string #15300

Open
2 tasks done
fraction01 opened this issue Mar 5, 2025 · 0 comments · May be fixed by #15304
Open
2 tasks done

Aggregation project stage doesn't accept string #15300

fraction01 opened this issue Mar 5, 2025 · 0 comments · May be fixed by #15304
Milestone

Comments

@fraction01
Copy link

fraction01 commented Mar 5, 2025

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

Node.js version

20

MongoDB server version

4.4

Typescript version (if applicable)

5.7.3

Description

project stage doesn't accept string as in the doc:

// include a, include b, exclude _id
aggregate.project("a b -_id");

Typescript error:

Argument of type 'string' is not assignable to parameter of type '{ [field: string]: any; }'.ts(2345)

I think string | is missing in

export interface Project {
/** [`$project` reference](https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/) */
$project: { [field: string]: AnyExpression | Expression | Project['$project'] }
}

Steps to Reproduce

Pass a string argument to the project stage

Expected Behavior

Should not show a Typescript error

@vkarpov15 vkarpov15 added this to the 7.8.7 milestone Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants