diff --git a/packages/angular-query-experimental/src/__tests__/query-options.test-d.ts b/packages/angular-query-experimental/src/__tests__/query-options.test-d.ts index c4462afaa3..03e84a0693 100644 --- a/packages/angular-query-experimental/src/__tests__/query-options.test-d.ts +++ b/packages/angular-query-experimental/src/__tests__/query-options.test-d.ts @@ -173,6 +173,19 @@ it('should return the proper type when passed to getQueryData', () => { expectTypeOf(data).toEqualTypeOf() }) +it('should return the proper type when passed to getQueryState', () => { + const key = queryKey() + const { queryKey: tagged } = queryOptions({ + queryKey: key, + queryFn: () => Promise.resolve(5), + }) + + const queryClient = new QueryClient() + const state = queryClient.getQueryState(tagged) + + expectTypeOf(state?.data).toEqualTypeOf() +}) + it('should properly type updaterFn when passed to setQueryData', () => { const key = queryKey() const { queryKey: tagged } = queryOptions({ @@ -207,3 +220,29 @@ it('should properly type value when passed to setQueryData', () => { expectTypeOf(data).toEqualTypeOf() }) + +it('should infer even if there is a conditional skipToken', () => { + const key = queryKey() + const options = queryOptions({ + queryKey: key, + queryFn: Math.random() > 0.5 ? skipToken : () => Promise.resolve(5), + }) + + const queryClient = new QueryClient() + const data = queryClient.getQueryData(options.queryKey) + + expectTypeOf(data).toEqualTypeOf() +}) + +it('should infer to unknown if we disable a query with just a skipToken', () => { + const key = queryKey() + const options = queryOptions({ + queryKey: key, + queryFn: skipToken, + }) + + const queryClient = new QueryClient() + const data = queryClient.getQueryData(options.queryKey) + + expectTypeOf(data).toEqualTypeOf() +})