-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d4a1080
commit 0ae1367
Showing
5 changed files
with
33 additions
and
4 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,19 @@ | ||
import * as mongoose from 'mongoose'; | ||
import { expectType } from 'tsd'; | ||
import * as bson from 'bson'; | ||
|
||
import GridFSBucket = mongoose.mongo.GridFSBucket; | ||
|
||
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