From a0cd934a2dd9e8f621d33d08516dc171a7da6788 Mon Sep 17 00:00:00 2001 From: hasezoey Date: Tue, 28 Jun 2022 11:24:07 +0200 Subject: [PATCH 1/2] test: extend test case for #11960 1 --- test/types/document.test.ts | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/test/types/document.test.ts b/test/types/document.test.ts index 3e703305e43..7dfddb3278a 100644 --- a/test/types/document.test.ts +++ b/test/types/document.test.ts @@ -227,14 +227,17 @@ 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(); + } } From b6b0973e2f13969c270f7eb266923ce88ddac5a1 Mon Sep 17 00:00:00 2001 From: hasezoey Date: Tue, 28 Jun 2022 11:24:26 +0200 Subject: [PATCH 2/2] test: extend test case for #11960 2 --- test/types/document.test.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/types/document.test.ts b/test/types/document.test.ts index 7dfddb3278a..3a26d4b15b9 100644 --- a/test/types/document.test.ts +++ b/test/types/document.test.ts @@ -240,4 +240,18 @@ async function gh11960() { 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(); + } }