File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
packages/openapi-react-query/test Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,29 @@ describe("client", () => {
64
64
client . queryOptions ( "get" , "/blogposts/{post_id}" , { } ) ;
65
65
} ) ;
66
66
67
+ it ( "correctly infers return type from query key" , async ( ) => {
68
+ const fetchClient = createFetchClient < paths > ( { baseUrl } ) ;
69
+ const client = createClient ( fetchClient ) ;
70
+
71
+ const data = queryClient . getQueryData (
72
+ client . queryOptions ( "get" , "/blogposts/{post_id}" , {
73
+ params : {
74
+ path : {
75
+ post_id : "1" ,
76
+ } ,
77
+ } ,
78
+ } ) . queryKey
79
+ ) ;
80
+
81
+ expectTypeOf ( data ) . toEqualTypeOf < {
82
+ title : string ;
83
+ body : string ;
84
+ publish_date ?: number ;
85
+ } | undefined > ( ) ;
86
+
87
+
88
+ } ) ;
89
+
67
90
it ( "returns query options that can resolve data correctly with fetchQuery" , async ( ) => {
68
91
const response = { title : "title" , body : "body" } ;
69
92
const fetchClient = createFetchClient < paths > ( { baseUrl } ) ;
You can’t perform that action at this time.
0 commit comments