Skip to content

Commit 39f651c

Browse files
authored
Merge pull request #12001 from hasezoey/extendTypesTestFor11960
Extend types test for #11960
2 parents fec4d6a + b6b0973 commit 39f651c

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

test/types/document.test.ts

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,31 @@ async function gh11960() {
227227

228228
const ParentModel = model<DocumentType<Parent>>('Parent', ParentSchema);
229229

230-
const doc = new ParentModel({
231-
username: 'user1',
232-
map: { key1: 'value1', key2: 'value2' },
233-
nested: { dummy: 'hello' },
234-
nestedArray: [{ dummy: 'hello again' }]
235-
});
236-
237-
expectType<Map<string, string> | undefined>(doc.map);
238-
doc.nested!.parent();
230+
{
231+
const doc = new ParentModel({
232+
username: 'user1',
233+
map: { key1: 'value1', key2: 'value2' },
234+
nested: { dummy: 'hello' },
235+
nestedArray: [{ dummy: 'hello again' }]
236+
});
237+
238+
expectType<Document<any, any, any> & Parent & { _id: Types.ObjectId }>(doc);
239+
expectType<Map<string, string> | undefined>(doc.map);
240+
doc.nested!.parent();
241+
doc.nestedArray?.[0].parentArray();
242+
}
239243

244+
{
245+
const doc = await ParentModel.create({
246+
username: 'user1',
247+
map: { key1: 'value1', key2: 'value2' },
248+
nested: { dummy: 'hello' },
249+
nestedArray: [{ dummy: 'hello again' }]
250+
});
251+
252+
expectType<Document<any, any, any> & Parent & { _id: Types.ObjectId }>(doc);
253+
expectType<Map<string, string> | undefined>(doc.map);
254+
doc.nested!.parent();
255+
doc.nestedArray?.[0].parentArray();
256+
}
240257
}

0 commit comments

Comments
 (0)