Skip to content

Commit d507e16

Browse files
committed
fix: non required - required parameters for InfiniteQuery
1 parent d9cc3b3 commit d507e16

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

.eslintrc.cjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = {
1010
'unicorn/prevent-abbreviations': 'off',
1111
'sonarjs/no-redundant-optional': 'off',
1212
'sonarjs/deprecation': 'off',
13-
'sonarjs/redundant-type-aliases': 'off'
13+
'sonarjs/redundant-type-aliases': 'off',
14+
'unicorn/no-useless-undefined': 'off'
1415
},
1516
};

src/infinite-query.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ class InfiniteQueryMock<
110110

111111
describe('InfiniteQuery', () => {
112112
it('should call queryFn without infinite query params', async () => {
113+
// @ts-expect-error
113114
const query = new InfiniteQueryMock({
114115
queryKey: ['test'],
115116
queryFn: () => {},
@@ -131,6 +132,7 @@ describe('InfiniteQuery', () => {
131132
const query = new InfiniteQueryMock({
132133
queryKey: ['test'],
133134
initialPageParam: 0,
135+
getNextPageParam: () => undefined,
134136
queryFn: () => {},
135137
});
136138

@@ -149,6 +151,7 @@ describe('InfiniteQuery', () => {
149151
it('should call queryFn with getNextPageParam', async () => {
150152
const query = new InfiniteQueryMock({
151153
queryKey: ['test'],
154+
initialPageParam: undefined,
152155
getNextPageParam: () => 1,
153156
queryFn: () => {},
154157
});
@@ -168,6 +171,7 @@ describe('InfiniteQuery', () => {
168171
it('should call queryFn with getNextPageParam returning null', async () => {
169172
const query = new InfiniteQueryMock({
170173
queryKey: ['test'],
174+
initialPageParam: undefined,
171175
getNextPageParam: () => null,
172176
queryFn: async () => 'data',
173177
});
@@ -409,6 +413,7 @@ describe('InfiniteQuery', () => {
409413
it('should be reactive after change queryKey', async () => {
410414
const query = new InfiniteQueryMock({
411415
queryKey: ['test', 0 as number] as const,
416+
initialPageParam: undefined,
412417
enabled: ({ queryKey }) => queryKey[1] > 0,
413418
getNextPageParam: () => 1,
414419
queryFn: () => 100,

src/inifinite-query.types.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export interface InfiniteQueryDynamicOptions<
3939
InfiniteQueryObserverOptions<
4040
TData,
4141
TError,
42-
InfiniteData<TData>,
42+
InfiniteData<TData, TPageParam>,
4343
TQueryKey,
4444
TPageParam
4545
>,
@@ -91,7 +91,7 @@ export interface InfiniteQueryUpdateOptions<
9191
InfiniteQueryObserverOptions<
9292
TData,
9393
TError,
94-
InfiniteData<TData>,
94+
InfiniteData<TData, TPageParam>,
9595
TQueryKey,
9696
TPageParam
9797
>
@@ -152,17 +152,15 @@ export interface InfiniteQueryConfig<
152152
TError = DefaultError,
153153
TQueryKey extends QueryKey = QueryKey,
154154
TPageParam = unknown,
155-
> extends Partial<
156-
Omit<
157-
InfiniteQueryObserverOptions<
158-
TData,
159-
TError,
160-
InfiniteData<TData>,
161-
TQueryKey,
162-
TPageParam
163-
>,
164-
'queryKey'
165-
>
155+
> extends Omit<
156+
InfiniteQueryObserverOptions<
157+
TData,
158+
TError,
159+
InfiniteData<TData, TPageParam>,
160+
TQueryKey,
161+
TPageParam
162+
>,
163+
'queryKey'
166164
>,
167165
QueryFeatures {
168166
queryClient: AnyQueryClient;

src/preset/create-infinite-query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const createInfiniteQuery = <
2424
TPageParam = unknown,
2525
>(
2626
fn: InfiniteQueryConfig<TData, TError, TQueryKey, TPageParam>['queryFn'],
27-
params?: CreateInfiniteQueryParams<TData, TError, TQueryKey, TPageParam>,
27+
params: CreateInfiniteQueryParams<TData, TError, TQueryKey, TPageParam>,
2828
) => {
2929
return new InfiniteQuery({
3030
...params,

0 commit comments

Comments
 (0)