@@ -164,21 +164,37 @@ function gh11503() {
164
164
interface User {
165
165
friends : Types . ObjectId [ ] ;
166
166
}
167
- const UserSchema = new Schema < User > ( {
167
+ const userSchema = new Schema < User > ( {
168
168
friends : [ { type : Schema . Types . ObjectId , ref : 'friends' } ]
169
169
} ) ;
170
- const Users = model < User > ( 'friends' , UserSchema ) ;
170
+ const User = model < User > ( 'friends' , userSchema ) ;
171
171
172
- Users . findOne ( { } ) . populate ( 'friends' ) . then ( user => {
172
+ User . findOne ( { } ) . populate ( 'friends' ) . then ( user => {
173
173
expectType < Types . ObjectId | undefined > ( user ?. friends [ 0 ] ) ;
174
174
expectError ( user ?. friends [ 0 ] . blocked ) ;
175
175
expectError ( user ?. friends . map ( friend => friend . blocked ) ) ;
176
176
} ) ;
177
177
178
- Users . findOne ( { } ) . populate < { friends : Friend [ ] } > ( 'friends' ) . then ( user => {
178
+ User . findOne ( { } ) . populate < { friends : Friend [ ] } > ( 'friends' ) . then ( user => {
179
179
expectAssignable < Friend > ( user ?. friends [ 0 ] ) ;
180
180
expectType < boolean > ( user ?. friends [ 0 ] . blocked ) ;
181
181
const firstFriendBlockedValue = user ?. friends . map ( friend => friend ) [ 0 ] ;
182
182
expectType < boolean > ( firstFriendBlockedValue ?. blocked ) ;
183
183
} ) ;
184
+ }
185
+
186
+
187
+ function gh11544 ( ) {
188
+
189
+ interface User {
190
+ friends : Types . ObjectId [ ] ;
191
+ }
192
+ const userSchema = new Schema < User > ( {
193
+ friends : [ { type : Schema . Types . ObjectId , ref : 'friends' } ]
194
+ } ) ;
195
+ const User = model < User > ( 'friends' , userSchema ) ;
196
+
197
+ User . findOne ( { } ) . populate ( { path : 'friends' , strictPopulate : false } ) ;
198
+ User . findOne ( { } ) . populate ( { path : 'friends' , strictPopulate : true } ) ;
199
+ User . findOne ( { } ) . populate ( { path : 'friends' , populate : { path : 'someNestedPath' , strictPopulate : false } } ) ;
184
200
}
0 commit comments