File tree Expand file tree Collapse file tree 2 files changed +26
-21
lines changed Expand file tree Collapse file tree 2 files changed +26
-21
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ import {
1212 FilterQuery ,
1313 UpdateQuery ,
1414 UpdateQueryKnownOnly ,
15- ApplyBasicQueryCasting ,
1615 QuerySelector ,
1716 InferSchemaType ,
1817 ProjectionFields ,
@@ -325,7 +324,7 @@ function gh11964() {
325324}
326325
327326function gh14397 ( ) {
328- type Condition < T > = ApplyBasicQueryCasting < T > | QuerySelector < ApplyBasicQueryCasting < T > > ; // redefined here because it's not exported by mongoose
327+ type Condition < T > = T | QuerySelector < T > ; // redefined here because it's not exported by mongoose
329328
330329 type WithId < T extends object > = T & { id : string } ;
331330
@@ -592,3 +591,24 @@ function mongooseQueryOptions() {
592591 populate : 'test'
593592 } ) ;
594593}
594+
595+ function gh14473 ( ) {
596+ class AbstractSchema {
597+ _id : any ;
598+ createdAt : Date ;
599+ updatedAt : Date ;
600+ deletedAt : Date ;
601+
602+ constructor ( ) {
603+ this . _id = 4 ;
604+ this . createdAt = new Date ( ) ;
605+ this . updatedAt = new Date ( ) ;
606+ this . deletedAt = new Date ( ) ;
607+ }
608+ }
609+
610+ const generateExists = < D extends AbstractSchema = AbstractSchema > ( ) => {
611+ const query : FilterQuery < D > = { deletedAt : { $ne : null } } ;
612+ const query2 : FilterQuery < D > = { deletedAt : { $lt : new Date ( ) } } ;
613+ } ;
614+ }
Original file line number Diff line number Diff line change 11declare module 'mongoose' {
22 import mongodb = require( 'mongodb' ) ;
33
4- type StringQueryTypeCasting = string | RegExp ;
5- type ObjectIdQueryTypeCasting = Types . ObjectId | string ;
6- type UUIDQueryTypeCasting = Types . UUID | string ;
7-
8- type QueryTypeCasting < T > = T extends string
9- ? StringQueryTypeCasting
10- : T extends Types . ObjectId
11- ? ObjectIdQueryTypeCasting
12- : T extends Types . UUID
13- ? UUIDQueryTypeCasting
14- : T | any ;
15-
16- export type ApplyBasicQueryCasting < T > = T | T [ ] | ( T extends ( infer U ) [ ] ? QueryTypeCasting < U > : T ) ;
17- export type Condition < T > = ApplyBasicQueryCasting < QueryTypeCasting < T > > | QuerySelector < ApplyBasicQueryCasting < QueryTypeCasting < T > > > ;
18-
19- type _FilterQuery < T > = {
20- [ P in keyof T ] ?: Condition < T [ P ] > ;
21- } & RootQuerySelector < T > ;
4+ export type Condition < T > = T | QuerySelector < T | any > | any ;
225
236 /**
247 * Filter query to select the documents that match the query
@@ -27,7 +10,9 @@ declare module 'mongoose' {
2710 * { age: { $gte: 30 } }
2811 * ```
2912 */
30- type FilterQuery < T > = _FilterQuery < T > ;
13+ type FilterQuery < T > = {
14+ [ P in keyof T ] ?: Condition < T [ P ] > ;
15+ } & RootQuerySelector < T > ;
3116
3217 type MongooseBaseQueryOptionKeys =
3318 | 'context'
You can’t perform that action at this time.
0 commit comments