Skip to content

Commit 3ce8060

Browse files
committed
WIP: fix some more tests re: #14954
1 parent 2638c9a commit 3ce8060

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

test/types/schema.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,7 +1734,7 @@ async function gh14451() {
17341734
of: String
17351735
},
17361736
myUUID: 'UUID'
1737-
});
1737+
} as const);
17381738

17391739
const Test = model('Test', exampleSchema);
17401740

@@ -1776,7 +1776,7 @@ function gh15244() {
17761776
}
17771777

17781778
async function schemaDouble() {
1779-
const schema = new Schema({ balance: 'Double' });
1779+
const schema = new Schema({ balance: 'Double' } as const);
17801780
const TestModel = model('Test', schema);
17811781

17821782
const doc = await TestModel.findOne().orFail();
@@ -1818,7 +1818,7 @@ function gh15412() {
18181818
const ScheduleEntrySchema = new Schema({
18191819
startDate: { type: Date, required: true },
18201820
endDate: { type: Date, required: false }
1821-
});
1821+
} as const);
18221822
const ScheduleEntry = model('ScheduleEntry', ScheduleEntrySchema);
18231823

18241824
type ScheduleEntryDoc = ReturnType<typeof ScheduleEntry['hydrate']>

types/inferrawdoctype.d.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,15 @@ declare module 'mongoose' {
107107
IfEquals<PathValueType, BigInt> extends true ? bigint :
108108
PathValueType extends 'bigint' | 'BigInt' | typeof Schema.Types.BigInt | typeof BigInt ? bigint :
109109
PathValueType extends 'uuid' | 'UUID' | typeof Schema.Types.UUID ? UUID :
110-
IfEquals<PathValueType, Schema.Types.UUID> extends true ? Buffer :
111-
PathValueType extends MapConstructor | 'Map' ? Map<string, ResolveRawPathType<Options['of']>> :
112-
IfEquals<PathValueType, typeof Schema.Types.Map> extends true ? Map<string, ResolveRawPathType<Options['of']>> :
113-
PathValueType extends ArrayConstructor ? any[] :
114-
PathValueType extends typeof Schema.Types.Mixed ? any:
115-
IfEquals<PathValueType, ObjectConstructor> extends true ? any:
116-
IfEquals<PathValueType, {}> extends true ? any:
117-
PathValueType extends typeof SchemaType ? PathValueType['prototype'] :
118-
PathValueType extends Record<string, any> ? InferRawDocType<PathValueType> :
119-
unknown;
110+
PathValueType extends 'double' | 'Double' | typeof Schema.Types.Double ? Types.Double :
111+
IfEquals<PathValueType, Schema.Types.UUID> extends true ? Buffer :
112+
PathValueType extends MapConstructor | 'Map' ? Map<string, ResolveRawPathType<Options['of']>> :
113+
IfEquals<PathValueType, typeof Schema.Types.Map> extends true ? Map<string, ResolveRawPathType<Options['of']>> :
114+
PathValueType extends ArrayConstructor ? any[] :
115+
PathValueType extends typeof Schema.Types.Mixed ? any:
116+
IfEquals<PathValueType, ObjectConstructor> extends true ? any:
117+
IfEquals<PathValueType, {}> extends true ? any:
118+
PathValueType extends typeof SchemaType ? PathValueType['prototype'] :
119+
PathValueType extends Record<string, any> ? InferRawDocType<PathValueType> :
120+
unknown;
120121
}

0 commit comments

Comments
 (0)