File tree 2 files changed +24
-1
lines changed 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -1010,3 +1010,26 @@ async function gh15369() {
1010
1010
throw error ;
1011
1011
}
1012
1012
}
1013
+
1014
+ async function gh15437 ( ) {
1015
+ interface Person {
1016
+ name : string ;
1017
+ age : number ;
1018
+ address : string ;
1019
+ }
1020
+
1021
+ const schema = new mongoose . Schema ( {
1022
+ name : String ,
1023
+ age : Number ,
1024
+ address : String
1025
+ } ) ;
1026
+ const PersonModel = model < Person > ( 'Person' , schema ) ;
1027
+
1028
+ const data = { name : 'John Doe' , age : 30 , address : '123 Main St' } ;
1029
+
1030
+ // Test hydrating with string projection
1031
+ const doc1 = PersonModel . hydrate ( data , 'name age' ) ;
1032
+ expectType < string > ( doc1 . name ) ;
1033
+ expectType < number > ( doc1 . age ) ;
1034
+ expectAssignable < undefined | null | string > ( doc1 . address ) ;
1035
+ }
Original file line number Diff line number Diff line change @@ -482,7 +482,7 @@ declare module 'mongoose' {
482
482
* Shortcut for creating a new Document from existing raw data, pre-saved in the DB.
483
483
* The document returned has no paths marked as modified initially.
484
484
*/
485
- hydrate ( obj : any , projection ?: AnyObject , options ?: HydrateOptions ) : THydratedDocumentType ;
485
+ hydrate ( obj : any , projection ?: ProjectionType < TRawDocType > , options ?: HydrateOptions ) : THydratedDocumentType ;
486
486
487
487
/**
488
488
* This function is responsible for building [indexes](https://www.mongodb.com/docs/manual/indexes/),
You can’t perform that action at this time.
0 commit comments