Skip to content

Commit d99775a

Browse files
kevin-dpclaude
andauthored
Make loadSubsetOptions optional in QueryCollectionMeta (#1238)
* Make loadSubsetOptions optional in QueryCollectionMeta Fixes #1061 - the required loadSubsetOptions property in QueryCollectionMeta was polluting all TanStack Query meta usages via the Register module augmentation, causing type errors for non-db-collection query meta. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Add changeset for optional loadSubsetOptions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 85c373e commit d99775a

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tanstack/query-db-collection': patch
3+
---
4+
5+
Make loadSubsetOptions optional in QueryCollectionMeta to fix query-core interface pollution (#1061)

packages/query-db-collection/src/global.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import type { LoadSubsetOptions } from '@tanstack/db'
2828
* ```
2929
*/
3030
export interface QueryCollectionMeta extends Record<string, unknown> {
31-
loadSubsetOptions: LoadSubsetOptions
31+
loadSubsetOptions?: LoadSubsetOptions
3232
}
3333

3434
// Module augmentation to extend TanStack Query's Register interface

packages/query-db-collection/tests/query.test-d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ describe(`Query collection type resolution tests`, () => {
440440
// Verify that loadSubsetOptions is assignable to LoadSubsetOptions
441441
// This ensures it can be used where LoadSubsetOptions is expected
442442
expectTypeOf(
443-
ctx.meta!.loadSubsetOptions,
443+
ctx.meta!.loadSubsetOptions!,
444444
).toExtend<LoadSubsetOptions>()
445445
// so that parseLoadSubsetOptions can be called without type errors
446446
parseLoadSubsetOptions(ctx.meta?.loadSubsetOptions)
@@ -465,7 +465,7 @@ describe(`Query collection type resolution tests`, () => {
465465
// Verify that an object with loadSubsetOptions plus other properties
466466
// can be assigned to ctx.meta's type. This ensures the type is not too restrictive.
467467
const metaWithExtra = {
468-
loadSubsetOptions: ctx.meta!.loadSubsetOptions,
468+
loadSubsetOptions: ctx.meta!.loadSubsetOptions!,
469469
customProperty: `test`,
470470
anotherProperty: 123,
471471
}
@@ -476,7 +476,7 @@ describe(`Query collection type resolution tests`, () => {
476476

477477
// Verify the assignment worked (this will fail at compile time if types don't match)
478478
expectTypeOf(
479-
typedMeta.loadSubsetOptions,
479+
typedMeta.loadSubsetOptions!,
480480
).toExtend<LoadSubsetOptions>()
481481

482482
return Promise.resolve([])

0 commit comments

Comments
 (0)