Skip to content

Why is any used as the type for Document.id? #13079

Open
@juona

Description

@juona

Prerequisites

  • I have written a descriptive issue title

Mongoose version

6.9.1

Node.js version

16

MongoDB version

5

Operating system

Linux

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

No response

Issue

The virtual id getter very clearly always returns a String:

function idGetter() {
  if (this._id != null) {
    return String(this._id);
  }

  return null;
}

However the type for the id field on Document objects is id?: any;.

Why not string? What am I not seeing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions