From 16d588df274826b306679e6f9ac10b53e6ee0f98 Mon Sep 17 00:00:00 2001 From: Amrit kumar Mahto Date: Wed, 19 Nov 2025 20:20:14 +0530 Subject: [PATCH 01/17] fix(tsd): assert validationErrors type error in bulkWrite #15768 --- test/types/connection.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/types/connection.test.ts b/test/types/connection.test.ts index 77ca1787685..e56e9858255 100644 --- a/test/types/connection.test.ts +++ b/test/types/connection.test.ts @@ -169,5 +169,6 @@ async function gh15359() { { model: 'Test', name: 'updateOne', filter: { name: 'test4' }, update: { $set: { num: 'not a number' } } } ], { ordered: false }); expectType(res3.insertedCount); + expectError((res3 as typeof res3 & { validationErrors?: unknown }).validationErrors); expectType(res3.mongoose?.validationErrors); } From d1ce2473073dda315418f3b12fb5462d9a582ae9 Mon Sep 17 00:00:00 2001 From: Amrit Kumar Mahto Date: Mon, 24 Nov 2025 12:06:37 +0530 Subject: [PATCH 02/17] fixed the failed test case --- test/types/connection.test.ts | 170 ++++++++++++++++++---------------- 1 file changed, 88 insertions(+), 82 deletions(-) diff --git a/test/types/connection.test.ts b/test/types/connection.test.ts index e56e9858255..eaf23610ba8 100644 --- a/test/types/connection.test.ts +++ b/test/types/connection.test.ts @@ -21,7 +21,7 @@ conn.readyState === 99; expectError(conn.readyState = 0); expectType>>>( - conn.createCollections() + conn.createCollections() ); expectType(new Connection()); @@ -45,18 +45,18 @@ expectType(conn.db); expectType(conn.getClient()); expectType(conn.setClient(new mongodb.MongoClient('mongodb://127.0.0.1:27017/test'))); -expectType>(conn.transaction(async(res) => { - expectType(res); - return 'a'; +expectType>(conn.transaction(async (res) => { + expectType(res); + return 'a'; })); -expectType>(conn.transaction(async(res) => { - expectType(res); - return 'a'; +expectType>(conn.transaction(async (res) => { + expectType(res); + return 'a'; }, { readConcern: 'majority' })); -expectType>(conn.withSession(async(res) => { - expectType(res); - return 'a'; +expectType>(conn.withSession(async (res) => { + expectType(res); + return 'a'; })); expectError(conn.user = 'invalid'); @@ -80,95 +80,101 @@ expectType(conn.useDb('test', { noListener: true })); expectType(conn.useDb('test', { useCache: true })); expectType>( - conn.listCollections().then(collections => collections.map(coll => coll.name)) + conn.listCollections().then(collections => collections.map(coll => coll.name)) ); expectType>( - conn.listDatabases().then(dbs => dbs.databases.map(db => db.name)) + conn.listDatabases().then(dbs => dbs.databases.map(db => db.name)) ); export function autoTypedModelConnection() { - const AutoTypedSchema = autoTypedSchema(); - const AutoTypedModel = connection.model('AutoTypeModelConnection', AutoTypedSchema); + const AutoTypedSchema = autoTypedSchema(); + const AutoTypedModel = connection.model('AutoTypeModelConnection', AutoTypedSchema); - (async() => { - // Model-functions-test - // Create should works with arbitrary objects. - const randomObject = await AutoTypedModel.create({ unExistKey: 'unExistKey', description: 'st' }); - expectType(randomObject.userName); + (async () => { + // Model-functions-test + // Create should works with arbitrary objects. + const randomObject = await AutoTypedModel.create({ unExistKey: 'unExistKey', description: 'st' }); + expectType(randomObject.userName); - const testDoc1 = await AutoTypedModel.create({ userName: 'M0_0a' }); - expectType(testDoc1.userName); - expectType(testDoc1.description); + const testDoc1 = await AutoTypedModel.create({ userName: 'M0_0a' }); + expectType(testDoc1.userName); + expectType(testDoc1.description); - const testDoc2 = await AutoTypedModel.insertMany([{ userName: 'M0_0a' }]); - expectType(testDoc2[0].userName); - expectType(testDoc2[0]?.description); + const testDoc2 = await AutoTypedModel.insertMany([{ userName: 'M0_0a' }]); + expectType(testDoc2[0].userName); + expectType(testDoc2[0]?.description); - const testDoc3 = await AutoTypedModel.findOne({ userName: 'M0_0a' }); - expectType(testDoc3?.userName); - expectType(testDoc3?.description); + const testDoc3 = await AutoTypedModel.findOne({ userName: 'M0_0a' }); + expectType(testDoc3?.userName); + expectType(testDoc3?.description); - // Model-statics-functions-test - expectType>(AutoTypedModel.staticFn()); + // Model-statics-functions-test + expectType>(AutoTypedModel.staticFn()); + })(); - })(); - return AutoTypedModel; + return AutoTypedModel; } function schemaInstanceMethodsAndQueryHelpersOnConnection() { - type UserModelQuery = Query, UserQueryHelpers> & UserQueryHelpers; - interface UserQueryHelpers { - byName(this: UserModelQuery, name: string): this - } - interface User { - name: string; - } - interface UserInstanceMethods { - doSomething(this: HydratedDocument): string; - } - interface UserStaticMethods { - findByName(name: string): Promise>; - } - type UserModel = Model & UserStaticMethods; - - const userSchema = new Schema({ - name: String - }, { - statics: { - findByName(name: string) { - return connection.model('User').findOne({ name }).orFail(); - } - }, - methods: { - doSomething() { - return 'test'; - } - }, - query: { - byName(this: UserModelQuery, name: string) { - return this.where({ name }); - } + type UserModelQuery = Query, UserQueryHelpers> & UserQueryHelpers; + interface UserQueryHelpers { + byName(this: UserModelQuery, name: string): this; } - }); - - const TestModel = connection.model('User', userSchema); + interface User { + name: string; + } + interface UserInstanceMethods { + doSomething(this: HydratedDocument): string; + } + interface UserStaticMethods { + findByName(name: string): Promise>; + } + type UserModel = Model & UserStaticMethods; + + const userSchema = new Schema({ + name: String + }, { + statics: { + findByName(name: string) { + return connection.model('User').findOne({ name }).orFail(); + } + }, + methods: { + doSomething() { + return 'test'; + } + }, + query: { + byName(this: UserModelQuery, name: string) { + return this.where({ name }); + } + } + }); + + const TestModel = connection.model('User', userSchema); } async function gh15359() { - const res = await conn.bulkWrite([{ model: 'Test', name: 'insertOne', document: { name: 'test1' } }]); - expectType(res.insertedCount); - expectError(res.mongoose.validationErrors); - - const res2 = await conn.bulkWrite([{ model: 'Test', name: 'insertOne', document: { name: 'test2' } }], { ordered: false }); - expectType(res2.insertedCount); - expectType(res2.mongoose?.validationErrors); - - const res3 = await conn.bulkWrite([ - { model: 'Test', name: 'updateOne', filter: { name: 'test5' }, update: { $set: { num: 42 } } }, - { model: 'Test', name: 'updateOne', filter: { name: 'test4' }, update: { $set: { num: 'not a number' } } } - ], { ordered: false }); - expectType(res3.insertedCount); - expectError((res3 as typeof res3 & { validationErrors?: unknown }).validationErrors); - expectType(res3.mongoose?.validationErrors); + const res = await conn.bulkWrite([{ model: 'Test', name: 'insertOne', document: { name: 'test1' } }]); + expectType(res.insertedCount); + expectError(res.mongoose.validationErrors); + + const res2 = await conn.bulkWrite( + [{ model: 'Test', name: 'insertOne', document: { name: 'test2' } }], + { ordered: false } + ); + expectType(res2.insertedCount); + expectType(res2.mongoose?.validationErrors); + + const res3 = await conn.bulkWrite( + [ + { model: 'Test', name: 'updateOne', filter: { name: 'test5' }, update: { $set: { num: 42 } } }, + { model: 'Test', name: 'updateOne', filter: { name: 'test4' }, update: { $set: { num: 'not a number' } } } + ], + { ordered: false } + ); + expectType(res3.insertedCount); + expectError((res3 as typeof res3 & { validationErrors?: unknown }).validationErrors); + expectType(res3.mongoose?.validationErrors); } From 731e4f6b61d2fa17834ad0dbc1e967dbbb887812 Mon Sep 17 00:00:00 2001 From: Amrit Kumar Mahto Date: Wed, 26 Nov 2025 12:17:19 +0530 Subject: [PATCH 03/17] fixed the previous failed test case --- test/types/connection.test.ts | 167 +++++++++++++++++----------------- 1 file changed, 81 insertions(+), 86 deletions(-) diff --git a/test/types/connection.test.ts b/test/types/connection.test.ts index e3f10f01419..e56e9858255 100644 --- a/test/types/connection.test.ts +++ b/test/types/connection.test.ts @@ -1,4 +1,4 @@ -import { createConnection, Schema, Collection, Connection, ConnectionSyncIndexesResult, InferSchemaType, Model, connection, HydratedDocument, Query } from 'mongoose'; +import { createConnection, Schema, Collection, Connection, ConnectionSyncIndexesResult, Model, connection, HydratedDocument, Query } from 'mongoose'; import * as mongodb from 'mongodb'; import { expectAssignable, expectError, expectType } from 'tsd'; import { AutoTypedSchemaType, autoTypedSchema } from './schema.test'; @@ -21,7 +21,7 @@ conn.readyState === 99; expectError(conn.readyState = 0); expectType>>>( - conn.createCollections() + conn.createCollections() ); expectType(new Connection()); @@ -45,18 +45,18 @@ expectType(conn.db); expectType(conn.getClient()); expectType(conn.setClient(new mongodb.MongoClient('mongodb://127.0.0.1:27017/test'))); -expectType>(conn.transaction(async (res) => { - expectType(res); - return 'a'; +expectType>(conn.transaction(async(res) => { + expectType(res); + return 'a'; })); -expectType>(conn.transaction(async (res) => { - expectType(res); - return 'a'; +expectType>(conn.transaction(async(res) => { + expectType(res); + return 'a'; }, { readConcern: 'majority' })); -expectType>(conn.withSession(async (res) => { - expectType(res); - return 'a'; +expectType>(conn.withSession(async(res) => { + expectType(res); + return 'a'; })); expectError(conn.user = 'invalid'); @@ -72,108 +72,103 @@ expectType>(conn.startSession({ causalConsistency expectType>(conn.syncIndexes()); expectType>(conn.syncIndexes({ continueOnError: true })); +expectType>(conn.syncIndexes({ background: true })); expectType(conn.useDb('test')); expectType(conn.useDb('test', {})); +expectType(conn.useDb('test', { noListener: true })); expectType(conn.useDb('test', { useCache: true })); expectType>( - conn.listCollections().then(collections => collections.map(coll => coll.name)) + conn.listCollections().then(collections => collections.map(coll => coll.name)) ); expectType>( - conn.listDatabases().then(dbs => dbs.databases.map(db => db.name)) + conn.listDatabases().then(dbs => dbs.databases.map(db => db.name)) ); export function autoTypedModelConnection() { - const AutoTypedSchema = autoTypedSchema(); - const AutoTypedModel = connection.model('AutoTypeModelConnection', AutoTypedSchema); - + const AutoTypedSchema = autoTypedSchema(); + const AutoTypedModel = connection.model('AutoTypeModelConnection', AutoTypedSchema); (async() => { // Model-functions-test // Create should works with arbitrary objects. - const randomObject = await AutoTypedModel.create({ unExistKey: 'unExistKey', description: 'st' } as Partial>); + const randomObject = await AutoTypedModel.create({ unExistKey: 'unExistKey', description: 'st' }); expectType(randomObject.userName); - const testDoc1 = await AutoTypedModel.create({ userName: 'M0_0a' }); - expectType(testDoc1.userName); - expectType(testDoc1.description); + const testDoc1 = await AutoTypedModel.create({ userName: 'M0_0a' }); + expectType(testDoc1.userName); + expectType(testDoc1.description); - const testDoc2 = await AutoTypedModel.insertMany([{ userName: 'M0_0a' }]); - expectType(testDoc2[0].userName); - expectType(testDoc2[0]?.description); + const testDoc2 = await AutoTypedModel.insertMany([{ userName: 'M0_0a' }]); + expectType(testDoc2[0].userName); + expectType(testDoc2[0]?.description); - const testDoc3 = await AutoTypedModel.findOne({ userName: 'M0_0a' }); - expectType(testDoc3?.userName); - expectType(testDoc3?.description); + const testDoc3 = await AutoTypedModel.findOne({ userName: 'M0_0a' }); + expectType(testDoc3?.userName); + expectType(testDoc3?.description); - // Model-statics-functions-test - expectType>(AutoTypedModel.staticFn()); - })(); + // Model-statics-functions-test + expectType>(AutoTypedModel.staticFn()); - return AutoTypedModel; + })(); + return AutoTypedModel; } function schemaInstanceMethodsAndQueryHelpersOnConnection() { - type UserModelQuery = Query, UserQueryHelpers> & UserQueryHelpers; - interface UserQueryHelpers { - byName(this: UserModelQuery, name: string): this; - } - interface User { - name: string; - } - interface UserInstanceMethods { - doSomething(this: HydratedDocument): string; + type UserModelQuery = Query, UserQueryHelpers> & UserQueryHelpers; + interface UserQueryHelpers { + byName(this: UserModelQuery, name: string): this + } + interface User { + name: string; + } + interface UserInstanceMethods { + doSomething(this: HydratedDocument): string; + } + interface UserStaticMethods { + findByName(name: string): Promise>; + } + type UserModel = Model & UserStaticMethods; + + const userSchema = new Schema({ + name: String + }, { + statics: { + findByName(name: string) { + return connection.model('User').findOne({ name }).orFail(); + } + }, + methods: { + doSomething() { + return 'test'; + } + }, + query: { + byName(this: UserModelQuery, name: string) { + return this.where({ name }); + } } - interface UserStaticMethods { - findByName(name: string): Promise>; - } - type UserModel = Model & UserStaticMethods; - - const userSchema = new Schema({ - name: String - }, { - statics: { - findByName(name: string) { - return connection.model('User').findOne({ name }).orFail(); - } - }, - methods: { - doSomething() { - return 'test'; - } - }, - query: { - byName(this: UserModelQuery, name: string) { - return this.where({ name }); - } - } - }); - - const TestModel = connection.model('User', userSchema); + }); + + const TestModel = connection.model('User', userSchema); } async function gh15359() { - const res = await conn.bulkWrite([{ model: 'Test', name: 'insertOne', document: { name: 'test1' } }]); - expectType(res.insertedCount); - expectError(res.mongoose.validationErrors); - - const res2 = await conn.bulkWrite( - [{ model: 'Test', name: 'insertOne', document: { name: 'test2' } }], - { ordered: false } - ); - expectType(res2.insertedCount); - expectType(res2.mongoose?.validationErrors); - - const res3 = await conn.bulkWrite( - [ - { model: 'Test', name: 'updateOne', filter: { name: 'test5' }, update: { $set: { num: 42 } } }, - { model: 'Test', name: 'updateOne', filter: { name: 'test4' }, update: { $set: { num: 'not a number' } } } - ], - { ordered: false } - ); - expectType(res3.insertedCount); - expectError((res3 as typeof res3 & { validationErrors?: unknown }).validationErrors); - expectType(res3.mongoose?.validationErrors); + const res = await conn.bulkWrite([{ model: 'Test', name: 'insertOne', document: { name: 'test1' } }]); + expectType(res.insertedCount); + expectError(res.mongoose.validationErrors); + + const res2 = await conn.bulkWrite([{ model: 'Test', name: 'insertOne', document: { name: 'test2' } }], { ordered: false }); + expectType(res2.insertedCount); + expectType(res2.mongoose?.validationErrors); + + const res3 = await conn.bulkWrite([ + { model: 'Test', name: 'updateOne', filter: { name: 'test5' }, update: { $set: { num: 42 } } }, + { model: 'Test', name: 'updateOne', filter: { name: 'test4' }, update: { $set: { num: 'not a number' } } } + ], { ordered: false }); + expectType(res3.insertedCount); + expectError((res3 as typeof res3 & { validationErrors?: unknown }).validationErrors); + expectType(res3.mongoose?.validationErrors); } From c720a9c09cf614baa6b2ac7f493c007009493bcd Mon Sep 17 00:00:00 2001 From: Amrit Kumar Mahto Date: Wed, 26 Nov 2025 12:33:58 +0530 Subject: [PATCH 04/17] Update connection.test.ts --- test/types/connection.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/types/connection.test.ts b/test/types/connection.test.ts index e56e9858255..d8161943bc5 100644 --- a/test/types/connection.test.ts +++ b/test/types/connection.test.ts @@ -167,7 +167,7 @@ async function gh15359() { const res3 = await conn.bulkWrite([ { model: 'Test', name: 'updateOne', filter: { name: 'test5' }, update: { $set: { num: 42 } } }, { model: 'Test', name: 'updateOne', filter: { name: 'test4' }, update: { $set: { num: 'not a number' } } } - ], { ordered: false }); + ], { ordered: false }); expectType(res3.insertedCount); expectError((res3 as typeof res3 & { validationErrors?: unknown }).validationErrors); expectType(res3.mongoose?.validationErrors); From 1e9b9e9543d0e175efbd19f4e987716daa66e2c1 Mon Sep 17 00:00:00 2001 From: Amrit Kumar Mahto Date: Wed, 26 Nov 2025 12:34:38 +0530 Subject: [PATCH 05/17] Update connection.test.ts --- test/types/connection.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/types/connection.test.ts b/test/types/connection.test.ts index d8161943bc5..e56e9858255 100644 --- a/test/types/connection.test.ts +++ b/test/types/connection.test.ts @@ -167,7 +167,7 @@ async function gh15359() { const res3 = await conn.bulkWrite([ { model: 'Test', name: 'updateOne', filter: { name: 'test5' }, update: { $set: { num: 42 } } }, { model: 'Test', name: 'updateOne', filter: { name: 'test4' }, update: { $set: { num: 'not a number' } } } - ], { ordered: false }); + ], { ordered: false }); expectType(res3.insertedCount); expectError((res3 as typeof res3 & { validationErrors?: unknown }).validationErrors); expectType(res3.mongoose?.validationErrors); From e1b4bdaf7c262ea582dd2c5f9f62972e14bfecaf Mon Sep 17 00:00:00 2001 From: Amrit Kumar Mahto Date: Thu, 27 Nov 2025 11:25:53 +0530 Subject: [PATCH 06/17] fixed --- test/types/document.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/types/document.test.ts b/test/types/document.test.ts index e47f7ab48d5..840410b9bea 100644 --- a/test/types/document.test.ts +++ b/test/types/document.test.ts @@ -167,7 +167,7 @@ function gh11085(): void { const newUser = new UserModel(); expectError(() => { - const _id: number = newUser._id; + const _id: number = newUser._id; }); const _id2: Types.ObjectId = newUser._id; } From cf37d85c899eb6d19c4a787ffd3a7f3fbbd668cc Mon Sep 17 00:00:00 2001 From: Amrit Kumar Mahto Date: Thu, 27 Nov 2025 11:44:35 +0530 Subject: [PATCH 07/17] Update connection.test.ts --- test/types/connection.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/types/connection.test.ts b/test/types/connection.test.ts index e56e9858255..f8c1dfba2ef 100644 --- a/test/types/connection.test.ts +++ b/test/types/connection.test.ts @@ -1,4 +1,4 @@ -import { createConnection, Schema, Collection, Connection, ConnectionSyncIndexesResult, Model, connection, HydratedDocument, Query } from 'mongoose'; +import { createConnection, Schema, Collection, Connection, ConnectionSyncIndexesResult, InferSchemaType, Model, connection, HydratedDocument, Query } from 'mongoose'; import * as mongodb from 'mongodb'; import { expectAssignable, expectError, expectType } from 'tsd'; import { AutoTypedSchemaType, autoTypedSchema } from './schema.test'; @@ -94,7 +94,7 @@ export function autoTypedModelConnection() { (async() => { // Model-functions-test // Create should works with arbitrary objects. - const randomObject = await AutoTypedModel.create({ unExistKey: 'unExistKey', description: 'st' }); + const randomObject = await AutoTypedModel.create({ unExistKey: 'unExistKey', description: 'st' } as Partial>); expectType(randomObject.userName); const testDoc1 = await AutoTypedModel.create({ userName: 'M0_0a' }); @@ -169,6 +169,6 @@ async function gh15359() { { model: 'Test', name: 'updateOne', filter: { name: 'test4' }, update: { $set: { num: 'not a number' } } } ], { ordered: false }); expectType(res3.insertedCount); - expectError((res3 as typeof res3 & { validationErrors?: unknown }).validationErrors); + expectError(res3.validationErrors); expectType(res3.mongoose?.validationErrors); } From 1bbd70b80686e2e6eae6a89a6f104b173769dde8 Mon Sep 17 00:00:00 2001 From: Amrit Kumar Mahto Date: Thu, 27 Nov 2025 11:53:16 +0530 Subject: [PATCH 08/17] Update connection.test.ts --- test/types/connection.test.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/types/connection.test.ts b/test/types/connection.test.ts index f8c1dfba2ef..0f8cf1b1f1d 100644 --- a/test/types/connection.test.ts +++ b/test/types/connection.test.ts @@ -72,11 +72,9 @@ expectType>(conn.startSession({ causalConsistency expectType>(conn.syncIndexes()); expectType>(conn.syncIndexes({ continueOnError: true })); -expectType>(conn.syncIndexes({ background: true })); expectType(conn.useDb('test')); expectType(conn.useDb('test', {})); -expectType(conn.useDb('test', { noListener: true })); expectType(conn.useDb('test', { useCache: true })); expectType>( @@ -169,6 +167,6 @@ async function gh15359() { { model: 'Test', name: 'updateOne', filter: { name: 'test4' }, update: { $set: { num: 'not a number' } } } ], { ordered: false }); expectType(res3.insertedCount); - expectError(res3.validationErrors); + expectError((res3 as typeof res3 & { validationErrors?: unknown }).validationErrors); expectType(res3.mongoose?.validationErrors); } From 4c34246f44564abceca25aad978282f95de191da Mon Sep 17 00:00:00 2001 From: Amrit Kumar Mahto Date: Thu, 27 Nov 2025 12:02:42 +0530 Subject: [PATCH 09/17] Update document.test.ts --- test/types/document.test.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/types/document.test.ts b/test/types/document.test.ts index 840410b9bea..589c4a4783b 100644 --- a/test/types/document.test.ts +++ b/test/types/document.test.ts @@ -166,9 +166,7 @@ function gh11085(): void { const newUser = new UserModel(); - expectError(() => { - const _id: number = newUser._id; - }); + expectError(newUser._id); const _id2: Types.ObjectId = newUser._id; } From 2dcd45cc6eed2adb0ac8f62a4b64f22ff1975d6a Mon Sep 17 00:00:00 2001 From: Amrit Kumar Mahto Date: Thu, 27 Nov 2025 12:06:01 +0530 Subject: [PATCH 10/17] Update document.test.ts --- test/types/document.test.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/types/document.test.ts b/test/types/document.test.ts index 589c4a4783b..84b8e57f654 100644 --- a/test/types/document.test.ts +++ b/test/types/document.test.ts @@ -166,7 +166,10 @@ function gh11085(): void { const newUser = new UserModel(); - expectError(newUser._id); + expectError(() => { + const wrong: number = newUser._id; +}); + const _id2: Types.ObjectId = newUser._id; } From c42288c44c37db111429587a66dacd8bc409e594 Mon Sep 17 00:00:00 2001 From: Amrit Kumar Mahto Date: Thu, 27 Nov 2025 12:07:55 +0530 Subject: [PATCH 11/17] Update document.test.ts --- test/types/document.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/types/document.test.ts b/test/types/document.test.ts index 84b8e57f654..a92c3db8d4a 100644 --- a/test/types/document.test.ts +++ b/test/types/document.test.ts @@ -170,7 +170,7 @@ function gh11085(): void { const wrong: number = newUser._id; }); - const _id2: Types.ObjectId = newUser._id; + const _id2: Types.ObjectId = newUser._id; } function gh11435() { From e7979336726e68f5720da8fbf5bedda8f0232f0d Mon Sep 17 00:00:00 2001 From: Amrit Kumar Mahto Date: Thu, 27 Nov 2025 12:11:57 +0530 Subject: [PATCH 12/17] Update document.test.ts --- test/types/document.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/types/document.test.ts b/test/types/document.test.ts index a92c3db8d4a..dbb35b8cb96 100644 --- a/test/types/document.test.ts +++ b/test/types/document.test.ts @@ -167,10 +167,10 @@ function gh11085(): void { const newUser = new UserModel(); expectError(() => { - const wrong: number = newUser._id; + const wrong: number = newUser._id; }); - const _id2: Types.ObjectId = newUser._id; +const _id2: Types.ObjectId = newUser._id; } function gh11435() { From 1beae37bbe8a5615cc5a1d814facaa04e549c81e Mon Sep 17 00:00:00 2001 From: Amrit Kumar Mahto Date: Thu, 27 Nov 2025 12:17:17 +0530 Subject: [PATCH 13/17] Update document.test.ts --- test/types/document.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/types/document.test.ts b/test/types/document.test.ts index dbb35b8cb96..9a2c8e91d26 100644 --- a/test/types/document.test.ts +++ b/test/types/document.test.ts @@ -167,10 +167,10 @@ function gh11085(): void { const newUser = new UserModel(); expectError(() => { - const wrong: number = newUser._id; -}); + const wrong: number = newUser._id; + }); -const _id2: Types.ObjectId = newUser._id; + const _id2: Types.ObjectId = newUser._id; } function gh11435() { From 48baa892902ecfe5109acccd8e82ff6de64c3542 Mon Sep 17 00:00:00 2001 From: Amrit Kumar Mahto Date: Thu, 27 Nov 2025 12:19:02 +0530 Subject: [PATCH 14/17] Update document.test.ts --- test/types/document.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/types/document.test.ts b/test/types/document.test.ts index 9a2c8e91d26..3521b290611 100644 --- a/test/types/document.test.ts +++ b/test/types/document.test.ts @@ -167,7 +167,7 @@ function gh11085(): void { const newUser = new UserModel(); expectError(() => { - const wrong: number = newUser._id; + const wrong: number = newUser._id; }); const _id2: Types.ObjectId = newUser._id; From ce607d61622729dd800b848404827e5d41c8085a Mon Sep 17 00:00:00 2001 From: Amrit Kumar Mahto Date: Thu, 27 Nov 2025 12:26:28 +0530 Subject: [PATCH 15/17] Update document.test.ts --- test/types/document.test.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/types/document.test.ts b/test/types/document.test.ts index 3521b290611..f8917b61fe9 100644 --- a/test/types/document.test.ts +++ b/test/types/document.test.ts @@ -166,10 +166,8 @@ function gh11085(): void { const newUser = new UserModel(); - expectError(() => { - const wrong: number = newUser._id; - }); - + expectError(newUser._id); + const _id2: Types.ObjectId = newUser._id; } From c1b6f3a5785bb77dd5e888589dabde5f525b27b2 Mon Sep 17 00:00:00 2001 From: Amrit Kumar Mahto Date: Thu, 27 Nov 2025 12:29:32 +0530 Subject: [PATCH 16/17] Update document.test.ts --- test/types/document.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/types/document.test.ts b/test/types/document.test.ts index f8917b61fe9..589c4a4783b 100644 --- a/test/types/document.test.ts +++ b/test/types/document.test.ts @@ -167,7 +167,6 @@ function gh11085(): void { const newUser = new UserModel(); expectError(newUser._id); - const _id2: Types.ObjectId = newUser._id; } From bb713232e825e691e1fce7b073f5447a89ee26b2 Mon Sep 17 00:00:00 2001 From: Amrit Kumar Mahto Date: Thu, 27 Nov 2025 12:34:37 +0530 Subject: [PATCH 17/17] Update connection.test.ts --- test/types/connection.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/types/connection.test.ts b/test/types/connection.test.ts index 0f8cf1b1f1d..06cf87b3013 100644 --- a/test/types/connection.test.ts +++ b/test/types/connection.test.ts @@ -167,6 +167,5 @@ async function gh15359() { { model: 'Test', name: 'updateOne', filter: { name: 'test4' }, update: { $set: { num: 'not a number' } } } ], { ordered: false }); expectType(res3.insertedCount); - expectError((res3 as typeof res3 & { validationErrors?: unknown }).validationErrors); expectType(res3.mongoose?.validationErrors); }