Skip to content

Commit 32bb9a2

Browse files
test(types): add type test re #12286 #12309
1 parent 59dd6af commit 32bb9a2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/types/models.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,3 +444,18 @@ function gh12100() {
444444
const doc = await User.exists({ name: 'Bill' }).orFail();
445445
expectType<Types.ObjectId>(doc._id);
446446
})();
447+
448+
449+
async function gh12286() {
450+
interface IUser{
451+
name: string;
452+
}
453+
const schema = new Schema<IUser>({
454+
name: { type: String, required: true }
455+
});
456+
457+
const User = model<IUser>('User', schema);
458+
459+
const user = await User.findById('0'.repeat(24), { name: 1 }).lean();
460+
expectType<IUser | null>(user);
461+
}

0 commit comments

Comments
 (0)