Skip to content

Aggregation project stage doesn't accept string #15300

Closed
@fraction01

Description

@fraction01

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions