Skip to content

BigInt type doesn't work as expected #14147

@akim-bow

Description

@akim-bow

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

Node.js version

18.x

MongoDB server version

6.x

Typescript version (if applicable)

5.2.2

Description

When i use BigInt type in mongoose schema, i cannot pass typecheck and assign BigInt value to it's property.

Steps to Reproduce

export const affiliateSchema = new Schema({
  balance: { type: BigInt, default: BigInt(0) },
});

const AffiliateModel = model("Affiliate", affiliateSchema);

AffiliateModel.findOne({})!.then(modelValue => {
  modelValue.balance = 123n;
});

image

Expected Behavior

No type error here.

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