Skip to content

Commit 369d95c

Browse files
aryaemami59markerikson
authored andcommitted
Fix duplicate types
# Conflicts: # packages/toolkit/src/query/endpointDefinitions.ts # packages/toolkit/src/query/react/buildHooks.ts
1 parent 2717292 commit 369d95c

File tree

10 files changed

+101
-95
lines changed

10 files changed

+101
-95
lines changed

packages/toolkit/src/query/core/apiState.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import type { SerializedError } from '@reduxjs/toolkit'
22
import type { BaseQueryError } from '../baseQueryTypes'
33
import type {
4-
QueryDefinition,
5-
MutationDefinition,
6-
EndpointDefinitions,
74
BaseEndpointDefinition,
8-
ResultTypeFrom,
9-
QueryArgFrom,
5+
EndpointDefinitions,
106
InfiniteQueryDefinition,
7+
MutationDefinition,
118
PageParamFrom,
9+
QueryArgFrom,
10+
QueryDefinition,
11+
ResultTypeFrom,
1212
} from '../endpointDefinitions'
1313
import type { Id, WithRequiredProp } from '../tsHelpers'
1414

packages/toolkit/src/query/core/buildInitiate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import type {
2+
SafePromise,
23
SerializedError,
34
ThunkAction,
45
ThunkDispatch,
56
UnknownAction,
67
} from '@reduxjs/toolkit'
78
import type { Dispatch } from 'redux'
8-
import type { SafePromise } from '../../tsHelpers'
99
import { asSafePromise } from '../../tsHelpers'
1010
import type { Api, ApiContext } from '../apiTypes'
1111
import type { BaseQueryError, QueryReturnValue } from '../baseQueryTypes'

packages/toolkit/src/query/core/buildMiddleware/cacheLifecycle.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,12 @@ export type CacheLifecycleInfiniteQueryExtraOptions<
148148
QueryArg,
149149
BaseQuery extends BaseQueryFn,
150150
ReducerPath extends string = string,
151-
> = {
152-
onCacheEntryAdded?(
153-
arg: QueryArg,
154-
api: QueryCacheLifecycleApi<QueryArg, BaseQuery, ResultType, ReducerPath>,
155-
): Promise<void> | void
156-
}
151+
> = CacheLifecycleQueryExtraOptions<
152+
ResultType,
153+
QueryArg,
154+
BaseQuery,
155+
ReducerPath
156+
>
157157

158158
export type CacheLifecycleMutationExtraOptions<
159159
ResultType,

packages/toolkit/src/query/core/buildMiddleware/queryLifecycle.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ export type QueryLifecycleInfiniteQueryExtraOptions<
122122
QueryArg,
123123
BaseQuery extends BaseQueryFn,
124124
ReducerPath extends string = string,
125-
> = {
126-
onQueryStarted?(
127-
arg: QueryArg,
128-
api: QueryLifecycleApi<QueryArg, BaseQuery, ResultType, ReducerPath>,
129-
): Promise<void> | void
130-
}
125+
> = QueryLifecycleQueryExtraOptions<
126+
ResultType,
127+
QueryArg,
128+
BaseQuery,
129+
ReducerPath
130+
>
131131

132132
export type QueryLifecycleMutationExtraOptions<
133133
ResultType,

packages/toolkit/src/query/core/buildSlice.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,17 @@ export function buildSlice({
202202
substate.startedTimeStamp = meta.startedTimeStamp
203203

204204
// TODO: Awful - fix this most likely by just moving it to its own slice that only works on InfQuery's
205-
if ('param' in substate && 'direction' in substate) {
206-
if ('param' in arg && 'direction' in arg) {
207-
substate.param = arg.param
208-
substate.direction = arg.direction as
209-
| 'forward'
210-
| 'backwards'
211-
| undefined
212-
}
205+
if (
206+
'param' in substate &&
207+
'direction' in substate &&
208+
'param' in arg &&
209+
'direction' in arg
210+
) {
211+
substate.param = arg.param
212+
substate.direction = arg.direction as
213+
| 'forward'
214+
| 'backwards'
215+
| undefined
213216
}
214217
})
215218
}

packages/toolkit/src/query/core/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ export const createApi = /* @__PURE__ */ buildCreateApi(coreModule())
66
export { QueryStatus } from './apiState'
77
export type {
88
CombinedState,
9+
InfiniteData,
10+
InfiniteQueryConfigOptions,
11+
InfiniteQuerySubState,
912
MutationKeys,
1013
QueryCacheKey,
1114
QueryKeys,
@@ -14,6 +17,7 @@ export type {
1417
SubscriptionOptions,
1518
} from './apiState'
1619
export type {
20+
InfiniteQueryActionCreatorResult,
1721
MutationActionCreatorResult,
1822
QueryActionCreatorResult,
1923
StartQueryActionCreatorOptions,
@@ -24,7 +28,7 @@ export type {
2428
QueryCacheLifecycleApi,
2529
QueryLifecycleApi,
2630
SubscriptionSelectors,
27-
} from './buildMiddleware'
31+
} from './buildMiddleware/index'
2832
export { skipToken } from './buildSelectors'
2933
export type {
3034
InfiniteQueryResultSelectorResult,
@@ -40,6 +44,7 @@ export type {
4044
} from './buildThunks'
4145
export { coreModuleName } from './module'
4246
export type {
47+
ApiEndpointInfiniteQuery,
4348
ApiEndpointMutation,
4449
ApiEndpointQuery,
4550
CoreModule,

packages/toolkit/src/query/endpointDefinitions.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
import type { Api } from '@reduxjs/toolkit/query'
2-
import type {
3-
InfiniteQueryConfigOptions,
4-
QuerySubState,
5-
RootState,
6-
} from './core/apiState'
72
import type {
83
BaseQueryApi,
94
BaseQueryArg,
@@ -25,6 +20,11 @@ import type {
2520
QueryLifecycleMutationExtraOptions,
2621
QueryLifecycleQueryExtraOptions,
2722
} from './core/buildMiddleware/queryLifecycle'
23+
import type {
24+
InfiniteQueryConfigOptions,
25+
QuerySubState,
26+
RootState,
27+
} from './core/index'
2828
import type { SerializeQueryArgs } from './defaultSerializeQueryArgs'
2929
import type { NEVER } from './fakeBaseQuery'
3030
import type {
@@ -43,7 +43,6 @@ type EndpointDefinitionWithQuery<
4343
QueryArg,
4444
BaseQuery extends BaseQueryFn,
4545
ResultType,
46-
PageParam = never,
4746
> = {
4847
/**
4948
* `query` can be a function that returns either a `string` or an `object` which is passed to your `baseQuery`. If you are using [fetchBaseQuery](./fetchBaseQuery), this can return either a `string` or an `object` of properties in `FetchArgs`. If you use your own custom [`baseQuery`](../../rtk-query/usage/customizing-queries), you can customize this behavior to your liking.
Lines changed: 49 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,7 @@
11
// This must remain here so that the `mangleErrors.cjs` build script
22
// does not have to import this into each source file it rewrites.
3-
import { formatProdErrorMessage } from '@reduxjs/toolkit'
43

5-
export type {
6-
CombinedState,
7-
InfiniteData,
8-
InfiniteQueryConfigOptions,
9-
QueryCacheKey,
10-
QueryKeys,
11-
QuerySubState,
12-
RootState,
13-
SubscriptionOptions,
14-
} from './core/apiState'
15-
export { QueryStatus } from './core/apiState'
164
export type { Api, ApiContext, Module } from './apiTypes'
17-
185
export type {
196
BaseQueryApi,
207
BaseQueryArg,
@@ -26,67 +13,78 @@ export type {
2613
BaseQueryResult,
2714
QueryReturnValue,
2815
} from './baseQueryTypes'
16+
export {
17+
QueryStatus,
18+
coreModule,
19+
coreModuleName,
20+
createApi,
21+
setupListeners,
22+
skipToken,
23+
} from './core/index'
24+
export type {
25+
ApiEndpointInfiniteQuery,
26+
ApiEndpointMutation,
27+
ApiEndpointQuery,
28+
CombinedState,
29+
CoreModule,
30+
InfiniteData,
31+
InfiniteQueryActionCreatorResult,
32+
InfiniteQueryConfigOptions,
33+
InfiniteQueryResultSelectorResult,
34+
MutationActionCreatorResult,
35+
MutationResultSelectorResult,
36+
PrefetchOptions,
37+
QueryActionCreatorResult,
38+
QueryCacheKey,
39+
QueryKeys,
40+
QueryResultSelectorResult,
41+
QuerySubState,
42+
RootState,
43+
SkipToken,
44+
StartQueryActionCreatorOptions,
45+
SubscriptionOptions,
46+
} from './core/index'
47+
export type { ApiModules } from './core/module'
48+
export { buildCreateApi } from './createApi'
49+
export type { CreateApi, CreateApiOptions } from './createApi'
50+
export { defaultSerializeQueryArgs } from './defaultSerializeQueryArgs'
51+
export type { SerializeQueryArgs } from './defaultSerializeQueryArgs'
2952
export type {
3053
BaseEndpointDefinition,
31-
EndpointDefinitions,
32-
EndpointDefinition,
54+
DefinitionType,
55+
DefinitionsFromApi,
3356
EndpointBuilder,
34-
QueryDefinition,
57+
EndpointDefinition,
58+
EndpointDefinitions,
59+
InfiniteQueryArgFrom,
3560
InfiniteQueryDefinition,
3661
InfiniteQueryExtraOptions,
3762
MutationDefinition,
3863
MutationExtraOptions,
39-
TagDescription,
64+
OverrideResultType,
65+
PageParamFrom,
4066
QueryArgFrom,
67+
QueryDefinition,
4168
QueryExtraOptions,
42-
ResultTypeFrom,
43-
DefinitionType,
44-
DefinitionsFromApi,
45-
OverrideResultType,
4669
ResultDescription,
70+
ResultTypeFrom,
71+
TagDescription,
4772
TagTypesFromApi,
4873
UpdateDefinitions,
4974
} from './endpointDefinitions'
75+
export { _NEVER, fakeBaseQuery } from './fakeBaseQuery'
5076
export { fetchBaseQuery } from './fetchBaseQuery'
5177
export type {
78+
FetchArgs,
5279
FetchBaseQueryArgs,
5380
FetchBaseQueryError,
5481
FetchBaseQueryMeta,
55-
FetchArgs,
5682
} from './fetchBaseQuery'
5783
export { retry } from './retry'
5884
export type { RetryOptions } from './retry'
59-
export { setupListeners } from './core/setupListeners'
60-
export { skipToken } from './core/buildSelectors'
61-
export type {
62-
QueryResultSelectorResult,
63-
MutationResultSelectorResult,
64-
SkipToken,
65-
} from './core/buildSelectors'
66-
export type {
67-
InfiniteQueryActionCreatorResult,
68-
QueryActionCreatorResult,
69-
MutationActionCreatorResult,
70-
StartQueryActionCreatorOptions,
71-
} from './core/buildInitiate'
72-
export type { CreateApi, CreateApiOptions } from './createApi'
73-
export { buildCreateApi } from './createApi'
74-
export { _NEVER, fakeBaseQuery } from './fakeBaseQuery'
75-
export { copyWithStructuralSharing } from './utils/copyWithStructuralSharing'
76-
export { createApi, coreModule, coreModuleName } from './core'
77-
export type {
78-
ApiEndpointMutation,
79-
ApiEndpointQuery,
80-
ApiEndpointInfiniteQuery,
81-
ApiModules,
82-
CoreModule,
83-
PrefetchOptions,
84-
} from './core/module'
85-
export { defaultSerializeQueryArgs } from './defaultSerializeQueryArgs'
86-
export type { SerializeQueryArgs } from './defaultSerializeQueryArgs'
87-
8885
export type {
8986
Id as TSHelpersId,
9087
NoInfer as TSHelpersNoInfer,
9188
Override as TSHelpersOverride,
9289
} from './tsHelpers'
90+
export { copyWithStructuralSharing } from './utils/copyWithStructuralSharing'

packages/toolkit/src/query/react/buildHooks.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ import type {
1313
BaseQueryFn,
1414
CoreModule,
1515
EndpointDefinitions,
16-
InfiniteData,
1716
InfiniteQueryActionCreatorResult,
18-
InfiniteQueryConfigOptions,
17+
InfiniteQueryArgFrom,
1918
InfiniteQueryDefinition,
19+
InfiniteQueryResultSelectorResult,
2020
MutationActionCreatorResult,
2121
MutationDefinition,
2222
MutationResultSelectorResult,
23+
PageParamFrom,
2324
PrefetchOptions,
2425
QueryActionCreatorResult,
2526
QueryArgFrom,
@@ -36,7 +37,11 @@ import type {
3637
TSHelpersNoInfer,
3738
TSHelpersOverride,
3839
} from '@reduxjs/toolkit/query'
39-
import { QueryStatus, skipToken } from '@reduxjs/toolkit/query'
40+
import {
41+
defaultSerializeQueryArgs,
42+
QueryStatus,
43+
skipToken,
44+
} from '@reduxjs/toolkit/query'
4045
import type { DependencyList } from 'react'
4146
import {
4247
useCallback,
@@ -48,13 +53,9 @@ import {
4853
useState,
4954
} from 'react'
5055
import { shallowEqual } from 'react-redux'
51-
import type { InfiniteQueryResultSelectorResult } from '../core/buildSelectors'
52-
import type { SubscriptionSelectors } from '../core/index'
53-
import { defaultSerializeQueryArgs } from '../defaultSerializeQueryArgs'
54-
import type {
55-
InfiniteQueryArgFrom,
56-
PageParamFrom,
57-
} from '../endpointDefinitions'
56+
57+
import type { SubscriptionSelectors } from '../core/buildMiddleware/index'
58+
import type { InfiniteData, InfiniteQueryConfigOptions } from '../core/index'
5859
import type { UninitializedValue } from './constants'
5960
import { UNINITIALIZED_VALUE } from './constants'
6061
import type { ReactHooksModuleOptions } from './module'

packages/toolkit/src/query/react/namedHooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import type { UseMutation, UseLazyQuery, UseQuery } from './buildHooks'
21
import type {
32
DefinitionType,
43
EndpointDefinitions,
54
MutationDefinition,
65
QueryDefinition,
76
} from '@reduxjs/toolkit/query'
7+
import type { UseLazyQuery, UseMutation, UseQuery } from './buildHooks'
88

99
type QueryHookNames<Definitions extends EndpointDefinitions> = {
1010
[K in keyof Definitions as Definitions[K] extends {

0 commit comments

Comments
 (0)