diff --git a/test/types/document.test.ts b/test/types/document.test.ts index 3e703305e43..3a26d4b15b9 100644 --- a/test/types/document.test.ts +++ b/test/types/document.test.ts @@ -227,14 +227,31 @@ async function gh11960() { const ParentModel = model>('Parent', ParentSchema); - const doc = new ParentModel({ - username: 'user1', - map: { key1: 'value1', key2: 'value2' }, - nested: { dummy: 'hello' }, - nestedArray: [{ dummy: 'hello again' }] - }); - - expectType | undefined>(doc.map); - doc.nested!.parent(); + { + const doc = new ParentModel({ + username: 'user1', + map: { key1: 'value1', key2: 'value2' }, + nested: { dummy: 'hello' }, + nestedArray: [{ dummy: 'hello again' }] + }); + + expectType & Parent & { _id: Types.ObjectId }>(doc); + expectType | undefined>(doc.map); + doc.nested!.parent(); + doc.nestedArray?.[0].parentArray(); + } + { + const doc = await ParentModel.create({ + username: 'user1', + map: { key1: 'value1', key2: 'value2' }, + nested: { dummy: 'hello' }, + nestedArray: [{ dummy: 'hello again' }] + }); + + expectType & Parent & { _id: Types.ObjectId }>(doc); + expectType | undefined>(doc.map); + doc.nested!.parent(); + doc.nestedArray?.[0].parentArray(); + } }