Skip to content

Commit cfbccec

Browse files
committed
add test of 13797
1 parent 97dec38 commit cfbccec

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

test/types/schema.test.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -1217,4 +1217,11 @@ function gh13800() {
12171217
expectType<string>(this.lastName);
12181218
expectError<string>(this.someOtherField);
12191219
});
1220-
}
1220+
}
1221+
1222+
async function gh13797() {
1223+
interface IUser {
1224+
name: string;
1225+
}
1226+
const schema2 = new Schema<IUser>({ name: { type: String, required: function () { expectType<IUser>(this); return true } } });
1227+
}

types/schematypes.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ declare module 'mongoose' {
3939

4040
type DefaultType<T> = T extends Schema.Types.Mixed ? any : Partial<ExtractMongooseArray<T>>;
4141

42-
class SchemaTypeOptions<T, EnforcedDocType = {}> {
42+
class SchemaTypeOptions<T, EnforcedDocType = any> {
4343
type?:
4444
T extends string ? StringSchemaDefinition :
4545
T extends number ? NumberSchemaDefinition :

0 commit comments

Comments
 (0)