Skip to content

Commit

Permalink
add infinite query option types to public api
Browse files Browse the repository at this point in the history
  • Loading branch information
arnoud-dv committed May 7, 2024
1 parent d62edad commit da3eab4
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/angular-query-experimental/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# API extractor
*.api.md
etc/**
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,26 @@ export type DefinedCreateQueryResult<
TDefinedQueryObserver = DefinedQueryObserverResult<TData, TError>,
> = MapToSignals<TDefinedQueryObserver>

// @public (undocumented)
export type DefinedInitialDataInfiniteOptions<
TQueryFnData,
TError = DefaultError,
TData = InfiniteData<TQueryFnData>,
TQueryKey extends QueryKey = QueryKey,
TPageParam = unknown,
> = CreateInfiniteQueryOptions<
TQueryFnData,
TError,
TData,
TQueryFnData,
TQueryKey,
TPageParam
> & {
initialData:
| NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>
| (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>)
}

// @public (undocumented)
export type DefinedInitialDataOptions<
TQueryFnData = unknown,
Expand All @@ -296,8 +316,6 @@ export type DefinedInitialDataOptions<
| (() => NonUndefinedGuard<TQueryFnData>)
}

// Warning: (ae-forgotten-export) The symbol "UndefinedInitialDataInfiniteOptions" needs to be exported by the entry point index.d.ts
//
// @public
export function infiniteQueryOptions<
TQueryFnData,
Expand All @@ -323,8 +341,6 @@ export function infiniteQueryOptions<
queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>>
}

// Warning: (ae-forgotten-export) The symbol "DefinedInitialDataInfiniteOptions" needs to be exported by the entry point index.d.ts
//
// @public
export function infiniteQueryOptions<
TQueryFnData,
Expand Down Expand Up @@ -521,6 +537,9 @@ export const injectQueryClient: {
): QueryClient
}

// @public (undocumented)
export type NonUndefinedGuard<T> = T extends undefined ? never : T

// @public
export function provideAngularQuery(
queryClient: QueryClient,
Expand Down Expand Up @@ -632,6 +651,24 @@ export function queryOptions<
queryKey: DataTag<TQueryKey, TQueryFnData>
}

// @public (undocumented)
export type UndefinedInitialDataInfiniteOptions<
TQueryFnData,
TError = DefaultError,
TData = InfiniteData<TQueryFnData>,
TQueryKey extends QueryKey = QueryKey,
TPageParam = unknown,
> = CreateInfiniteQueryOptions<
TQueryFnData,
TError,
TData,
TQueryFnData,
TQueryKey,
TPageParam
> & {
initialData?: undefined
}

// @public (undocumented)
export type UndefinedInitialDataOptions<
TQueryFnData = unknown,
Expand All @@ -644,9 +681,5 @@ export type UndefinedInitialDataOptions<

export * from '@tanstack/query-core'

// Warnings were encountered during analysis:
//
// src/query-options.ts:27:3 - (ae-forgotten-export) The symbol "NonUndefinedGuard" needs to be exported by the entry point index.d.ts

// (No @packageDocumentation comment for this package)
```
4 changes: 4 additions & 0 deletions packages/angular-query-experimental/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export type {
} from './query-options'
export { queryOptions } from './query-options'

export type {
DefinedInitialDataInfiniteOptions,
UndefinedInitialDataInfiniteOptions,
} from './infinite-query-options'
export { infiniteQueryOptions } from './infinite-query-options'

export * from './inject-infinite-query'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { DataTag } from '@tanstack/query-core'
import type { InfiniteData } from '@tanstack/query-core'
import type { CreateInfiniteQueryOptions } from './types'
import type { CreateInfiniteQueryOptions, NonUndefinedGuard } from './types'
import type { DefaultError, QueryKey } from '@tanstack/query-core'

/**
Expand All @@ -23,8 +23,6 @@ export type UndefinedInitialDataInfiniteOptions<
initialData?: undefined
}

type NonUndefinedGuard<T> = T extends undefined ? never : T

/**
* @public
*/
Expand Down
4 changes: 1 addition & 3 deletions packages/angular-query-experimental/src/query-options.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { DataTag, DefaultError, QueryKey } from '@tanstack/query-core'
import type { CreateQueryOptions } from './types'
import type { CreateQueryOptions, NonUndefinedGuard } from './types'

/**
* @public
Expand All @@ -13,8 +13,6 @@ export type UndefinedInitialDataOptions<
initialData?: undefined
}

type NonUndefinedGuard<T> = T extends undefined ? never : T

/**
* @public
*/
Expand Down
5 changes: 5 additions & 0 deletions packages/angular-query-experimental/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,8 @@ type Override<TTargetA, TTargetB> = {
? TTargetB[AKey]
: TTargetA[AKey]
}

/**
* @public
*/
export type NonUndefinedGuard<T> = T extends undefined ? never : T

0 comments on commit da3eab4

Please sign in to comment.