Skip to content

Commit 64a30d8

Browse files
authored
Merge pull request #2373 from reduxjs/bugfix/ts-47-compat
2 parents 937471f + ceca051 commit 64a30d8

File tree

23 files changed

+57
-181
lines changed

23 files changed

+57
-181
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ jobs:
9696
fail-fast: false
9797
matrix:
9898
node: ['14.x']
99-
ts: ['4.1', '4.2', '4.3', '4.4', '4.5', '4.6.1-rc', 'next']
99+
ts: ['4.1', '4.2', '4.3', '4.4', '4.5', '4.6', '4.7']
100100
steps:
101101
- name: Checkout repo
102102
uses: actions/checkout@v2

examples/query/react/authentication-with-extrareducers/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"@emotion/styled": "^11.3.0",
1212
"@reduxjs/toolkit": "^1.6.0-rc.1",
1313
"framer-motion": "^2.9.5",
14-
"msw": "0.28.2",
14+
"msw": "^0.41.1",
1515
"react": "17.0.2",
1616
"react-dom": "17.0.2",
1717
"react-icons": "3.11.0",

examples/query/react/authentication/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"@emotion/styled": "^11.3.0",
1212
"@reduxjs/toolkit": "^1.6.0-rc.1",
1313
"framer-motion": "^2.9.5",
14-
"msw": "0.28.2",
14+
"msw": "^0.41.1",
1515
"react": "17.0.2",
1616
"react-dom": "17.0.2",
1717
"react-icons": "3.11.0",

examples/query/react/basic/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@types/react": "17.0.0",
1919
"@types/react-dom": "17.0.0",
2020
"@types/react-redux": "7.1.9",
21-
"msw": "^0.30.0",
21+
"msw": "^0.41.1",
2222
"typescript": "~4.2.4"
2323
},
2424
"eslintConfig": {

examples/query/react/kitchen-sink/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"main": "src/index.tsx",
88
"dependencies": {
99
"@reduxjs/toolkit": "1.8.1",
10-
"msw": "^0.39.2",
10+
"msw": "^0.41.1",
1111
"react": "17.0.0",
1212
"react-dom": "17.0.0",
1313
"react-redux": "7.2.2",

examples/query/react/mutations/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"@mswjs/data": "^0.3.0",
1313
"@reduxjs/toolkit": "^1.6.0-rc.1",
1414
"framer-motion": "^2.9.5",
15-
"msw": "0.28.2",
15+
"msw": "^0.41.1",
1616
"react": "17.0.2",
1717
"react-dom": "17.0.2",
1818
"react-icons": "3.11.0",

examples/query/react/optimistic-update/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"@mswjs/data": "^0.3.0",
1313
"@reduxjs/toolkit": "^1.6.0-rc.1",
1414
"framer-motion": "^2.9.5",
15-
"msw": "0.28.2",
15+
"msw": "^0.41.1",
1616
"react": "17.0.2",
1717
"react-dom": "17.0.2",
1818
"react-icons": "3.11.0",

examples/query/react/pagination/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@reduxjs/toolkit": "^1.6.0-rc.1",
1414
"faker": "^5.5.3",
1515
"framer-motion": "^2.9.5",
16-
"msw": "0.28.2",
16+
"msw": "^0.41.1",
1717
"react": "17.0.2",
1818
"react-dom": "17.0.2",
1919
"react-icons": "3.11.0",

examples/query/react/prefetching-automatic-waterfall/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@reduxjs/toolkit": "^1.6.0-rc.1",
1414
"faker": "^5.5.3",
1515
"framer-motion": "^2.9.5",
16-
"msw": "0.28.2",
16+
"msw": "^0.41.1",
1717
"react": "17.0.2",
1818
"react-dom": "17.0.2",
1919
"react-icons": "3.11.0",

examples/query/react/prefetching-automatic/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@reduxjs/toolkit": "^1.6.0-rc.1",
1414
"faker": "^5.5.3",
1515
"framer-motion": "^2.9.5",
16-
"msw": "0.28.2",
16+
"msw": "^0.41.1",
1717
"react": "17.0.2",
1818
"react-dom": "17.0.2",
1919
"react-icons": "3.11.0",

examples/query/react/prefetching/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@reduxjs/toolkit": "^1.6.0-rc.1",
1414
"faker": "^5.5.3",
1515
"framer-motion": "^2.9.5",
16-
"msw": "0.28.2",
16+
"msw": "^0.41.1",
1717
"react": "17.0.2",
1818
"react-dom": "17.0.2",
1919
"react-icons": "3.11.0",

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
"console-testing-library": "patch:console-testing-library@npm:0.3.1#.yarn/patches/console-testing-library__npm_0.3.1.patch",
4242
"react-redux": "npm:7.2.4",
4343
"react": "npm:17.0.2",
44-
"react-dom": "npm:17.0.2"
44+
"react-dom": "npm:17.0.2",
45+
"@types/inquirer": "npm:8.2.1"
4546
},
4647
"scripts": {
4748
"build": "yarn build:packages",

packages/rtk-query-codegen-openapi/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"esbuild-runner": "^2.2.1",
4848
"husky": "^4.3.6",
4949
"jest": "^26.6.3",
50-
"msw": "^0.25.0",
50+
"msw": "^0.41.1",
5151
"openapi-types": "^9.1.0",
5252
"pretty-quick": "^3.1.0",
5353
"ts-jest": "^26.4.4",

packages/rtk-query-codegen-openapi/test/mocks/server.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,8 @@ import petstoreYAML from '../fixtures/petstore.yaml.mock';
77
// This configures a request mocking server with the given request handlers.
88

99
export const server = setupServer(
10-
rest.get('https://example.com/echo', (req, res, ctx) =>
11-
res(ctx.json({ ...req, headers: req.headers.getAllHeaders() }))
12-
),
13-
rest.post('https://example.com/echo', (req, res, ctx) =>
14-
res(ctx.json({ ...req, headers: req.headers.getAllHeaders() }))
15-
),
10+
rest.get('https://example.com/echo', (req, res, ctx) => res(ctx.json({ ...req, headers: req.headers.all() }))),
11+
rest.post('https://example.com/echo', (req, res, ctx) => res(ctx.json({ ...req, headers: req.headers.all() }))),
1612

1713
rest.get('https://petstore3.swagger.io/api/v3/openapi.json', (req, res, ctx) => res(ctx.json(petstoreJSON))),
1814
rest.get('https://petstore3.swagger.io/api/v3/openapi.yaml', (req, res, ctx) =>

packages/toolkit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"json-stringify-safe": "^5.0.1",
6464
"magic-string": "^0.25.7",
6565
"merge-source-map": "^1.1.0",
66-
"msw": "^0.28.2",
66+
"msw": "^0.41.1",
6767
"node-fetch": "^2.6.1",
6868
"prettier": "^2.2.1",
6969
"query-string": "^7.0.1",

packages/toolkit/src/configureStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export function configureStore<
144144
if (typeof reducer === 'function') {
145145
rootReducer = reducer
146146
} else if (isPlainObject(reducer)) {
147-
rootReducer = combineReducers(reducer)
147+
rootReducer = combineReducers(reducer) as unknown as Reducer<S, A>
148148
} else {
149149
throw new Error(
150150
'"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers'

packages/toolkit/src/createAsyncThunk.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,14 +530,16 @@ export function createAsyncThunk<
530530
typeof AbortController !== 'undefined'
531531
? AbortController
532532
: class implements AbortController {
533-
signal: AbortSignal = {
533+
signal = {
534534
aborted: false,
535535
addEventListener() {},
536536
dispatchEvent() {
537537
return false
538538
},
539539
onabort() {},
540540
removeEventListener() {},
541+
reason: undefined,
542+
throwIfAborted() {},
541543
}
542544
abort() {
543545
if (process.env.NODE_ENV !== 'production') {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export type UseLazyQueryLastPromiseInfo<
188188
* When the trigger function returned from a LazyQuery, it always initiates a new request to the server even if there is cached data. Set `preferCacheValue`(the second argument to the function) as `true` if you want it to immediately return a cached value if one exists.
189189
*/
190190
export type UseLazyQuery<D extends QueryDefinition<any, any, any, any>> = <
191-
R = UseQueryStateDefaultResult<D>
191+
R extends Record<string, any> = UseQueryStateDefaultResult<D>
192192
>(
193193
options?: SubscriptionOptions & Omit<UseQueryStateOptions<D, R>, 'skip'>
194194
) => [
@@ -257,7 +257,7 @@ export type QueryStateSelector<
257257
* - Re-renders as the request status changes and data becomes available
258258
*/
259259
export type UseQueryState<D extends QueryDefinition<any, any, any, any>> = <
260-
R = UseQueryStateDefaultResult<D>
260+
R extends Record<string, any> = UseQueryStateDefaultResult<D>
261261
>(
262262
arg: QueryArgFrom<D> | SkipToken,
263263
options?: UseQueryStateOptions<D, R>

packages/toolkit/src/query/retry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const retryWithBackoff: BaseQueryEnhancer<
6161
throw new HandledError(result)
6262
}
6363
return result
64-
} catch (e) {
64+
} catch (e: any) {
6565
retry++
6666
if (e.throwImmediately || retry > options.maxRetries) {
6767
if (e instanceof HandledError) {

packages/toolkit/src/query/tests/createApi.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ test('providesTags and invalidatesTags can use baseQueryMeta', async () => {
731731
type SuccessResponse = { value: 'success' }
732732

733733
const api = createApi({
734-
baseQuery: fetchBaseQuery({ baseUrl: 'http://example.com' }),
734+
baseQuery: fetchBaseQuery({ baseUrl: 'https://example.com' }),
735735
tagTypes: ['success'],
736736
endpoints: (build) => ({
737737
query: build.query<SuccessResponse, void>({
@@ -754,7 +754,6 @@ test('providesTags and invalidatesTags can use baseQueryMeta', async () => {
754754
const storeRef = setupApiStore(api)
755755

756756
await storeRef.store.dispatch(api.endpoints.query.initiate())
757-
758757
expect('request' in _meta! && 'response' in _meta!).toBe(true)
759758

760759
_meta = undefined

packages/toolkit/src/query/tests/devWarnings.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ If you have multiple apis, you *have* to specify the reducerPath option when usi
273273
describe('`console.error` on unhandled errors during `initiate`', () => {
274274
test('error thrown in `baseQuery`', async () => {
275275
const api = createApi({
276-
baseQuery() {
276+
baseQuery(): { data: any } {
277277
throw new Error('this was kinda expected')
278278
},
279279
endpoints: (build) => ({

packages/toolkit/src/query/tests/unionTypes.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ describe.skip('TS only tests', () => {
349349
const useQueryStateWithSelectFromResult = api.endpoints.test.useQueryState(
350350
undefined,
351351
{
352-
selectFromResult: () => true,
352+
selectFromResult: () => ({ x: true }),
353353
}
354354
)
355355

0 commit comments

Comments
 (0)