Open History to see the last commit
1/**
2 * Global type augmentation for @tanstack/query-core
3 *
4 * This file ensures the module augmentation is always loaded when the package is imported.
5 * The index.ts file re-exports QueryCollectionMeta from this file, which guarantees
6 * TypeScript processes this file (and its module augmentation) whenever anyone imports
7 * from @tanstack/query-db-collection.
8 *
9 * This makes ctx.meta?.loadSubsetOptions automatically type-safe without requiring
10 * users to manually import QueryCollectionMeta.
11 */
12
13import type { LoadSubsetOptions } from '@tanstack/db'
14
15/**
16 * Base interface for Query Collection meta properties.
17 * Users can extend this interface to add their own custom properties while
18 * preserving loadSubsetOptions.
19 *
20 * @example
21 * ```typescript
22 * declare module "@tanstack/query-db-collection" {
23 * interface QueryCollectionMeta {
24 * myCustomProperty: string
25 * userId?: number
26 * }
27 * }
28 * ```
29 */
30export interface QueryCollectionMeta extends Record<string, unknown> {
31 loadSubsetOptions?: LoadSubsetOptions
32}
33
34// Module augmentation to extend TanStack Query's Register interface
35// This ensures that ctx.meta always includes loadSubsetOptions
36declare module '@tanstack/query-core' {
37 interface Register {
38 queryMeta: QueryCollectionMeta
39 }
40}