Skip to content

Commit 36cf381

Browse files
authored
fix(tanstack-query): narrow live options defaults type (#1568)
## Summary - Narrow experimental_liveOptions defaults to QueryOptionsIn instead of StreamedOptionsIn - Add a type test ensuring streamed-only queryFnOptions is rejected for live defaults ## Tests - pnpm --filter @orpc/tanstack-query type:check - pnpm vitest run packages/tanstack-query/src/procedure-utils.test.ts - pnpm run type:check - pnpm exec eslint --max-warnings=0 packages/tanstack-query/src/procedure-utils.ts packages/tanstack-query/src/procedure-utils.test-d.ts <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Fixed type validation for the experimental live query feature to use correct type definitions and enforce requirements properly. * **Tests** * Added type assertions to ensure the experimental live query options correctly validate input and reject incompatible configurations. <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/middleapi/orpc/pull/1568?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 1378fd2 commit 36cf381

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎packages/tanstack-query/src/procedure-utils.test-d.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ describe('ProcedureUtilsDefaults', () => {
852852
}
853853
})
854854

855-
it('experimental_liveOptions should accept Partial<StreamedOptionsIn>', () => {
855+
it('experimental_liveOptions should accept Partial<QueryOptionsIn>', () => {
856856
const defaults: TestDefaults = {
857857
experimental_liveOptions: {
858858
input: { search: 'test' },
@@ -867,6 +867,13 @@ describe('ProcedureUtilsDefaults', () => {
867867
input: { invalid: 'test' },
868868
},
869869
}
870+
871+
const _invalidStreamedOption: TestDefaults = {
872+
experimental_liveOptions: {
873+
// @ts-expect-error - queryFnOptions is only supported by experimental_streamedOptions
874+
queryFnOptions: { maxChunks: 10 },
875+
},
876+
}
870877
})
871878

872879
it('infiniteKey should accept Partial input, initialPageParam, queryKey', () => {

‎packages/tanstack-query/src/procedure-utils.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export interface experimental_ProcedureUtilsDefaults<TClientContext extends Clie
198198
* @see {@link https://orpc.dev/docs/integrations/tanstack-query#live-query-options Tanstack Live Query Options Utility Docs}
199199
*/
200200
experimental_liveOptions?: Partial<
201-
StreamedOptionsIn<TClientContext, TInput, experimental_LiveQueryOutput<TOutput>, TError, unknown>
201+
QueryOptionsIn<TClientContext, TInput, experimental_LiveQueryOutput<TOutput>, TError, unknown>
202202
>
203203

204204
/**

0 commit comments

Comments
 (0)