Skip to content

Commit

Permalink
Merge pull request #15115 from Automattic/vkarpov15/gh-15101
Browse files Browse the repository at this point in the history
types: add UUID to RefType
  • Loading branch information
vkarpov15 authored Dec 18, 2024
2 parents c00b674 + 585abde commit e436f6a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/typescript/populate.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ However, we recommend using the `.populate<{ child: Child }>` syntax from the fi
Here's two reasons why:

1. You still need to add an extra check to check if `child instanceof ObjectId`. Otherwise, the TypeScript compiler will fail with `Property name does not exist on type ObjectId`. So using `PopulatedDoc<>` means you need an extra check everywhere you use `doc.child`.
2. In the `Parent` interface, `child` is a hydrated document, which makes it slow difficult for Mongoose to infer the type of `child` when you use `lean()` or `toObject()`.
2. In the `Parent` interface, `child` is a hydrated document, which makes it difficult for Mongoose to infer the type of `child` when you use `lean()` or `toObject()`.
3 changes: 2 additions & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,8 @@ declare module 'mongoose' {
| typeof Schema.Types.Number
| typeof Schema.Types.String
| typeof Schema.Types.Buffer
| typeof Schema.Types.ObjectId;
| typeof Schema.Types.ObjectId
| typeof Schema.Types.UUID;


export type InferId<T> = T extends { _id?: any } ? T['_id'] : Types.ObjectId;
Expand Down

0 comments on commit e436f6a

Please sign in to comment.