File tree Expand file tree Collapse file tree 5 files changed +30
-3
lines changed Expand file tree Collapse file tree 5 files changed +30
-3
lines changed Original file line number Diff line number Diff line change 5050 "eslint-plugin-markdown" : " ^3.0.0" ,
5151 "eslint-plugin-mocha-no-only" : " 1.1.1" ,
5252 "express" : " ^4.18.1" ,
53+ "fs-extra" : " ~11.1.1" ,
5354 "highlight.js" : " 11.7.0" ,
5455 "lodash.isequal" : " 4.5.0" ,
5556 "lodash.isequalwith" : " 4.4.0" ,
6768 "tsd" : " 0.25.0" ,
6869 "typescript" : " 4.9.5" ,
6970 "uuid" : " 9.0.0" ,
70- "webpack" : " 5.75.0" ,
71- "fs-extra" : " ~11.1.1"
71+ "webpack" : " 5.75.0"
7272 },
7373 "directories" : {
7474 "lib" : " ./lib/mongoose"
Original file line number Diff line number Diff line change 1+ import * as mongoose from 'mongoose' ;
2+ import { expectType } from 'tsd' ;
3+ import * as bson from 'bson' ;
4+
5+ function gh12537 ( ) {
6+ const schema = new mongoose . Schema ( { test : String } ) ;
7+ const model = mongoose . model ( 'Test' , schema ) ;
8+
9+ const doc = new model ( { } ) ;
10+
11+ const v = new bson . ObjectId ( 'somehex' ) ;
12+ expectType < string > ( v . _id . toHexString ( ) ) ;
13+
14+ doc . _id = new bson . ObjectId ( 'somehex' ) ;
15+ }
16+
17+ gh12537 ( ) ;
Original file line number Diff line number Diff line change 1+ // this import is required so that types get merged instead of completely overwritten
2+ import 'bson' ;
3+
4+ declare module 'bson' {
5+ interface ObjectId {
6+ /** Mongoose automatically adds a conveniency "_id" getter on the base ObjectId class */
7+ _id : this;
8+ }
9+ }
Original file line number Diff line number Diff line change 2222/// <reference path="./validation.d.ts" />
2323/// <reference path="./inferschematype.d.ts" />
2424/// <reference path="./virtuals.d.ts" />
25+ /// <reference path="./augmentations.d.ts" />
2526
2627declare class NativeDate extends global . Date { }
2728
Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ declare module 'mongoose' {
8080 }
8181
8282 class ObjectId extends mongodb . ObjectId {
83- _id : this ;
83+
8484 }
8585
8686 class Subdocument < IdType = any > extends Document < IdType > {
You can’t perform that action at this time.
0 commit comments