@@ -13,39 +13,44 @@ export type FragmentType<TDocumentType extends DocumentTypeDecoration<any, any>>
1313 : never ;
1414
1515// return non-nullable if `fragmentType` is non-nullable
16- export function useFragment < F extends DocumentTypeDecoration < any , any > > (
17- _documentNode : F ,
18- fragmentType : FragmentType < F >
19- ) : ResultOf < F > ;
16+ export function useFragment < TType > (
17+ _documentNode : DocumentTypeDecoration < TType , any > ,
18+ fragmentType : FragmentType < DocumentTypeDecoration < TType , any > >
19+ ) : TType ;
2020// return nullable if `fragmentType` is undefined
21- export function useFragment < F extends DocumentTypeDecoration < any , any > > (
22- _documentNode : F ,
23- fragmentType : FragmentType < F > | undefined
24- ) : ResultOf < F > | undefined ;
21+ export function useFragment < TType > (
22+ _documentNode : DocumentTypeDecoration < TType , any > ,
23+ fragmentType : FragmentType < DocumentTypeDecoration < TType , any > > | undefined
24+ ) : TType | undefined ;
2525// return nullable if `fragmentType` is nullable
26- export function useFragment < F extends DocumentTypeDecoration < any , any > > (
27- _documentNode : F ,
28- fragmentType : FragmentType < F > | null
29- ) : ResultOf < F > | null ;
26+ export function useFragment < TType > (
27+ _documentNode : DocumentTypeDecoration < TType , any > ,
28+ fragmentType : FragmentType < DocumentTypeDecoration < TType , any > > | null
29+ ) : TType | null ;
3030// return nullable if `fragmentType` is nullable or undefined
31- export function useFragment < F extends DocumentTypeDecoration < any , any > > (
32- _documentNode : F ,
33- fragmentType : FragmentType < F > | null | undefined
34- ) : ResultOf < F > | null | undefined ;
31+ export function useFragment < TType > (
32+ _documentNode : DocumentTypeDecoration < TType , any > ,
33+ fragmentType : FragmentType < DocumentTypeDecoration < TType , any > > | null | undefined
34+ ) : TType | null | undefined ;
3535// return array of non-nullable if `fragmentType` is array of non-nullable
36- export function useFragment < F extends DocumentTypeDecoration < any , any > > (
37- _documentNode : F ,
38- fragmentType : ReadonlyArray < FragmentType < F > >
39- ) : ReadonlyArray < ResultOf < F > > ;
36+ export function useFragment < TType > (
37+ _documentNode : DocumentTypeDecoration < TType , any > ,
38+ fragmentType : ReadonlyArray < FragmentType < DocumentTypeDecoration < TType , any > > >
39+ ) : ReadonlyArray < TType > ;
4040// return array of nullable if `fragmentType` is array of nullable
41- export function useFragment < F extends DocumentTypeDecoration < any , any > > (
42- _documentNode : F ,
43- fragmentType : ReadonlyArray < FragmentType < F > > | null | undefined
44- ) : ReadonlyArray < ResultOf < F > > | null | undefined ;
45- export function useFragment < F extends DocumentTypeDecoration < any , any > > (
46- _documentNode : F ,
47- fragmentType : FragmentType < F > | ReadonlyArray < FragmentType < F > > | null | undefined
48- ) : ResultOf < F > | ReadonlyArray < ResultOf < F > > | null | undefined {
41+ export function useFragment < TType > (
42+ _documentNode : DocumentTypeDecoration < TType , any > ,
43+ fragmentType : ReadonlyArray < FragmentType < DocumentTypeDecoration < TType , any > > > | null | undefined
44+ ) : ReadonlyArray < TType > | null | undefined ;
45+ export function useFragment < TType > (
46+ _documentNode : DocumentTypeDecoration < TType , any > ,
47+ fragmentType :
48+ | FragmentType < DocumentTypeDecoration < TType , any > >
49+ | Array < FragmentType < DocumentTypeDecoration < TType , any > > >
50+ | ReadonlyArray < FragmentType < DocumentTypeDecoration < TType , any > > >
51+ | null
52+ | undefined
53+ ) : TType | Array < TType > | ReadonlyArray < TType > | null | undefined {
4954 return fragmentType as any ;
5055}
5156
@@ -69,5 +74,5 @@ export function isFragmentReady<TQuery, TFrag>(
6974 const fragName = fragDef ?. name ?. value ;
7075
7176 const fields = ( fragName && deferredFields [ fragName ] ) || [ ] ;
72- return fields . length > 0 && fields . every ( ( field : keyof TFrag ) => data && field in data ) ;
77+ return fields . length > 0 && fields . every ( field => data && field in data ) ;
7378}
0 commit comments