Skip to content

insertMany return type changed from version 7.3.2 to 7.3.3 #13957

Closed
@ksyd9821

Description

@ksyd9821

Prerequisites

  • I have written a descriptive issue title

Mongoose version

=7.3.3

Node.js version

18.x

MongoDB version

6.x

Operating system

Windows

Operating system version (i.e. 20.04, 11.3, 10)

No response

Issue

It seems that the return type of the insertMany function changed with version 7.3.3.
The following code runs without any error on v7.3.2 and lower

import * as mongoose from "mongoose";

export class RepositoryBase<T> {
    protected model: mongoose.Model<T & mongoose.Document>;

    constructor(schemaModel: mongoose.Model<T & mongoose.Document>) {
        this.model = schemaModel;
    }

    async insertMany(elems: T[]): Promise<T[]> {
        elems = await this.model.insertMany(elems);
        return elems;
    }
}

while on versions >=7.3.3 the assignment inside the function generates this error:
image

The typescript version is 5.2.2.

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