-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13723 from Automattic/IslandRhythms/backport-13515
backport pull 13515
- Loading branch information
Showing
5 changed files
with
30 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import * as mongoose from 'mongoose'; | ||
import { expectType } from 'tsd'; | ||
import * as bson from 'bson'; | ||
|
||
function gh12537() { | ||
const schema = new mongoose.Schema({ test: String }); | ||
const model = mongoose.model('Test', schema); | ||
|
||
const doc = new model({}); | ||
|
||
const v = new bson.ObjectId('somehex'); | ||
expectType<string>(v._id.toHexString()); | ||
|
||
doc._id = new bson.ObjectId('somehex'); | ||
} | ||
|
||
gh12537(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// this import is required so that types get merged instead of completely overwritten | ||
import 'bson'; | ||
|
||
declare module 'bson' { | ||
interface ObjectId { | ||
/** Mongoose automatically adds a conveniency "_id" getter on the base ObjectId class */ | ||
_id: this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters