File tree 5 files changed +30
-3
lines changed 5 files changed +30
-3
lines changed Original file line number Diff line number Diff line change 50
50
"eslint-plugin-markdown" : " ^3.0.0" ,
51
51
"eslint-plugin-mocha-no-only" : " 1.1.1" ,
52
52
"express" : " ^4.18.1" ,
53
+ "fs-extra" : " ~11.1.1" ,
53
54
"highlight.js" : " 11.7.0" ,
54
55
"lodash.isequal" : " 4.5.0" ,
55
56
"lodash.isequalwith" : " 4.4.0" ,
67
68
"tsd" : " 0.25.0" ,
68
69
"typescript" : " 4.9.5" ,
69
70
"uuid" : " 9.0.0" ,
70
- "webpack" : " 5.75.0" ,
71
- "fs-extra" : " ~11.1.1"
71
+ "webpack" : " 5.75.0"
72
72
},
73
73
"directories" : {
74
74
"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 22
22
/// <reference path="./validation.d.ts" />
23
23
/// <reference path="./inferschematype.d.ts" />
24
24
/// <reference path="./virtuals.d.ts" />
25
+ /// <reference path="./augmentations.d.ts" />
25
26
26
27
declare class NativeDate extends global . Date { }
27
28
Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ declare module 'mongoose' {
80
80
}
81
81
82
82
class ObjectId extends mongodb . ObjectId {
83
- _id : this ;
83
+
84
84
}
85
85
86
86
class Subdocument < IdType = any > extends Document < IdType > {
You can’t perform that action at this time.
0 commit comments