@@ -7,6 +7,7 @@ import type {
77 SelectType ,
88 Sort ,
99 TransformDataWithSelect ,
10+ TypedCollectionSelect ,
1011 TypeWithID ,
1112 Where ,
1213} from 'payload'
@@ -33,27 +34,35 @@ export type DataFromGlobalSlug<
3334export type SelectFromCollectionSlug <
3435 T extends PayloadTypesShape ,
3536 TSlug extends CollectionSlug < T > ,
36- > = SelectType & T [ 'collectionsSelect' ] [ TSlug ]
37+ > = TSlug extends keyof T [ 'collectionsSelect' ] ? T [ 'collectionsSelect' ] [ TSlug ] : SelectType
3738
3839export type SelectFromGlobalSlug <
3940 T extends PayloadTypesShape ,
4041 TSlug extends GlobalSlug < T > ,
41- > = SelectType & T [ 'globalsSelect' ] [ TSlug ]
42+ > = TSlug extends keyof T [ 'globalsSelect' ] ? T [ 'globalsSelect' ] [ TSlug ] : SelectType
4243
4344export type TransformCollectionWithSelect <
4445 T extends PayloadTypesShape ,
4546 TSlug extends CollectionSlug < T > ,
4647 TSelect ,
4748> = TSelect extends SelectType
48- ? TransformDataWithSelect < ( JsonObject & TypeWithID ) & T [ 'collections' ] [ TSlug ] , TSelect >
49+ ? TransformDataWithSelect <
50+ T [ 'collections' ] [ TSlug ] extends JsonObject
51+ ? T [ 'collections' ] [ TSlug ]
52+ : JsonObject & TypeWithID ,
53+ TSelect
54+ >
4955 : T [ 'collections' ] [ TSlug ]
5056
5157export type TransformGlobalWithSelect <
5258 T extends PayloadTypesShape ,
5359 TSlug extends GlobalSlug < T > ,
5460 TSelect ,
5561> = TSelect extends SelectType
56- ? TransformDataWithSelect < JsonObject & T [ 'globals' ] [ TSlug ] , TSelect >
62+ ? TransformDataWithSelect <
63+ T [ 'globals' ] [ TSlug ] extends JsonObject ? T [ 'globals' ] [ TSlug ] : JsonObject & TypeWithID ,
64+ TSelect
65+ >
5766 : T [ 'globals' ] [ TSlug ]
5867
5968type SystemFields = 'createdAt' | 'id' | 'sizes' | 'updatedAt'
0 commit comments