Skip to content

Commit 2086872

Browse files
committed
move _id type creation up in MongoProject<>
1 parent 0e9f98d commit 2086872

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

env.d.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -865,8 +865,8 @@ type BrainContext = Replace<CliContext, { /** Whether the script is being run vi
865865
// when anyField: true is given, other fields (except _id) are omitted
866866

867867
type MongoProject<TDocument, TProjection> =
868-
true extends (1 extends TProjection[keyof TProjection] ? true : TProjection[keyof TProjection]) ?
869-
(TProjection extends { _id: false | 0 } ? {} : { _id: TDocument extends { _id: infer TId } ? TId : MongoId }) &
868+
(TProjection extends { _id: false | 0 } ? {} : { _id: TDocument extends { _id: infer TId } ? TId : MongoId }) & (
869+
true extends (1 extends TProjection[keyof TProjection] ? true : TProjection[keyof TProjection]) ?
870870
{
871871
[K in
872872
keyof TDocument as K extends keyof TProjection ? TProjection[K] extends true | 1 ? K : never : never
@@ -877,7 +877,8 @@ type MongoProject<TDocument, TProjection> =
877877
keyof TProjection as TProjection[K] extends true | 1 ? K extends keyof TDocument ? never : K : never
878878
]?: MongoValue
879879
}
880-
: { [k: string]: MongoValue } & { [K in keyof TDocument as K extends keyof TProjection ? never : K]: TDocument[K] }
880+
: { [k: string]: MongoValue } & { [K in keyof TDocument as K extends keyof TProjection ? never : K]: TDocument[K] }
881+
)
881882

882883
type DeepFreeze<T> = { readonly [P in keyof T]: DeepFreeze<T[P]> }
883884

0 commit comments

Comments
 (0)