You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.
Not sure if this is a limitation of typescript but it seems like it cannot infer fragment types from a query response.
constdata=useLazyLoadQuery<SubmitTagsScreenQuery>(graphql` query SubmitTagsScreenQuery { viewer { ...SubmitTagsScreen_viewer } } `);constviewer=useFragment(graphql` fragment SubmitTagsScreen_viewer on Viewer { ... } `,data.viewer,);
(property) viewer: {
readonly " $fragmentRefs": FragmentRefs<"SubmitTagsScreen_viewer">;
}
No overload matches this call.
The last overload gave the following error.
Argument of type '{ readonly " $fragmentRefs": FragmentRefs<"SubmitTagsScreen_viewer">; }' is not assignable to parameter of type 'readonly { readonly ' $data'?: unknown; }[]'.
Type '{ readonly " $fragmentRefs": FragmentRefs<"SubmitTagsScreen_viewer">; }' is missing the following properties from type 'readonly { readonly ' $data'?: unknown; }[]': length, concat, join, slice, and 18 more.ts(2769)
useFragment.d.ts(36, 17): The last overload is declared here.
The problem is that the generated type for queries only contains $fragmentRefs and the one for the generic parameter of useFragment only $data meaning there is no overlap between the types which causes the error.
Not sure if this is a limitation of typescript but it seems like it cannot infer fragment types from a query response.
Adding an annotation to useFragment does fix it
The text was updated successfully, but these errors were encountered: