Skip to content

Commit

Permalink
Merge pull request #2373 from reduxjs/bugfix/ts-47-compat
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson authored May 30, 2022
2 parents 937471f + ceca051 commit 64a30d8
Show file tree
Hide file tree
Showing 23 changed files with 57 additions and 181 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
fail-fast: false
matrix:
node: ['14.x']
ts: ['4.1', '4.2', '4.3', '4.4', '4.5', '4.6.1-rc', 'next']
ts: ['4.1', '4.2', '4.3', '4.4', '4.5', '4.6', '4.7']
steps:
- name: Checkout repo
uses: actions/checkout@v2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"@emotion/styled": "^11.3.0",
"@reduxjs/toolkit": "^1.6.0-rc.1",
"framer-motion": "^2.9.5",
"msw": "0.28.2",
"msw": "^0.41.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-icons": "3.11.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/query/react/authentication/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"@emotion/styled": "^11.3.0",
"@reduxjs/toolkit": "^1.6.0-rc.1",
"framer-motion": "^2.9.5",
"msw": "0.28.2",
"msw": "^0.41.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-icons": "3.11.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/query/react/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@types/react": "17.0.0",
"@types/react-dom": "17.0.0",
"@types/react-redux": "7.1.9",
"msw": "^0.30.0",
"msw": "^0.41.1",
"typescript": "~4.2.4"
},
"eslintConfig": {
Expand Down
2 changes: 1 addition & 1 deletion examples/query/react/kitchen-sink/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"main": "src/index.tsx",
"dependencies": {
"@reduxjs/toolkit": "1.8.1",
"msw": "^0.39.2",
"msw": "^0.41.1",
"react": "17.0.0",
"react-dom": "17.0.0",
"react-redux": "7.2.2",
Expand Down
2 changes: 1 addition & 1 deletion examples/query/react/mutations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@mswjs/data": "^0.3.0",
"@reduxjs/toolkit": "^1.6.0-rc.1",
"framer-motion": "^2.9.5",
"msw": "0.28.2",
"msw": "^0.41.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-icons": "3.11.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/query/react/optimistic-update/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@mswjs/data": "^0.3.0",
"@reduxjs/toolkit": "^1.6.0-rc.1",
"framer-motion": "^2.9.5",
"msw": "0.28.2",
"msw": "^0.41.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-icons": "3.11.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/query/react/pagination/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@reduxjs/toolkit": "^1.6.0-rc.1",
"faker": "^5.5.3",
"framer-motion": "^2.9.5",
"msw": "0.28.2",
"msw": "^0.41.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-icons": "3.11.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@reduxjs/toolkit": "^1.6.0-rc.1",
"faker": "^5.5.3",
"framer-motion": "^2.9.5",
"msw": "0.28.2",
"msw": "^0.41.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-icons": "3.11.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/query/react/prefetching-automatic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@reduxjs/toolkit": "^1.6.0-rc.1",
"faker": "^5.5.3",
"framer-motion": "^2.9.5",
"msw": "0.28.2",
"msw": "^0.41.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-icons": "3.11.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/query/react/prefetching/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@reduxjs/toolkit": "^1.6.0-rc.1",
"faker": "^5.5.3",
"framer-motion": "^2.9.5",
"msw": "0.28.2",
"msw": "^0.41.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-icons": "3.11.0",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
"console-testing-library": "patch:console-testing-library@npm:0.3.1#.yarn/patches/console-testing-library__npm_0.3.1.patch",
"react-redux": "npm:7.2.4",
"react": "npm:17.0.2",
"react-dom": "npm:17.0.2"
"react-dom": "npm:17.0.2",
"@types/inquirer": "npm:8.2.1"
},
"scripts": {
"build": "yarn build:packages",
Expand Down
2 changes: 1 addition & 1 deletion packages/rtk-query-codegen-openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"esbuild-runner": "^2.2.1",
"husky": "^4.3.6",
"jest": "^26.6.3",
"msw": "^0.25.0",
"msw": "^0.41.1",
"openapi-types": "^9.1.0",
"pretty-quick": "^3.1.0",
"ts-jest": "^26.4.4",
Expand Down
8 changes: 2 additions & 6 deletions packages/rtk-query-codegen-openapi/test/mocks/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@ import petstoreYAML from '../fixtures/petstore.yaml.mock';
// This configures a request mocking server with the given request handlers.

export const server = setupServer(
rest.get('https://example.com/echo', (req, res, ctx) =>
res(ctx.json({ ...req, headers: req.headers.getAllHeaders() }))
),
rest.post('https://example.com/echo', (req, res, ctx) =>
res(ctx.json({ ...req, headers: req.headers.getAllHeaders() }))
),
rest.get('https://example.com/echo', (req, res, ctx) => res(ctx.json({ ...req, headers: req.headers.all() }))),
rest.post('https://example.com/echo', (req, res, ctx) => res(ctx.json({ ...req, headers: req.headers.all() }))),

rest.get('https://petstore3.swagger.io/api/v3/openapi.json', (req, res, ctx) => res(ctx.json(petstoreJSON))),
rest.get('https://petstore3.swagger.io/api/v3/openapi.yaml', (req, res, ctx) =>
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"json-stringify-safe": "^5.0.1",
"magic-string": "^0.25.7",
"merge-source-map": "^1.1.0",
"msw": "^0.28.2",
"msw": "^0.41.1",
"node-fetch": "^2.6.1",
"prettier": "^2.2.1",
"query-string": "^7.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/src/configureStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export function configureStore<
if (typeof reducer === 'function') {
rootReducer = reducer
} else if (isPlainObject(reducer)) {
rootReducer = combineReducers(reducer)
rootReducer = combineReducers(reducer) as unknown as Reducer<S, A>
} else {
throw new Error(
'"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers'
Expand Down
4 changes: 3 additions & 1 deletion packages/toolkit/src/createAsyncThunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,14 +530,16 @@ export function createAsyncThunk<
typeof AbortController !== 'undefined'
? AbortController
: class implements AbortController {
signal: AbortSignal = {
signal = {
aborted: false,
addEventListener() {},
dispatchEvent() {
return false
},
onabort() {},
removeEventListener() {},
reason: undefined,
throwIfAborted() {},
}
abort() {
if (process.env.NODE_ENV !== 'production') {
Expand Down
4 changes: 2 additions & 2 deletions packages/toolkit/src/query/react/buildHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export type UseLazyQueryLastPromiseInfo<
* 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.
*/
export type UseLazyQuery<D extends QueryDefinition<any, any, any, any>> = <
R = UseQueryStateDefaultResult<D>
R extends Record<string, any> = UseQueryStateDefaultResult<D>
>(
options?: SubscriptionOptions & Omit<UseQueryStateOptions<D, R>, 'skip'>
) => [
Expand Down Expand Up @@ -257,7 +257,7 @@ export type QueryStateSelector<
* - Re-renders as the request status changes and data becomes available
*/
export type UseQueryState<D extends QueryDefinition<any, any, any, any>> = <
R = UseQueryStateDefaultResult<D>
R extends Record<string, any> = UseQueryStateDefaultResult<D>
>(
arg: QueryArgFrom<D> | SkipToken,
options?: UseQueryStateOptions<D, R>
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/src/query/retry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const retryWithBackoff: BaseQueryEnhancer<
throw new HandledError(result)
}
return result
} catch (e) {
} catch (e: any) {
retry++
if (e.throwImmediately || retry > options.maxRetries) {
if (e instanceof HandledError) {
Expand Down
3 changes: 1 addition & 2 deletions packages/toolkit/src/query/tests/createApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ test('providesTags and invalidatesTags can use baseQueryMeta', async () => {
type SuccessResponse = { value: 'success' }

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

await storeRef.store.dispatch(api.endpoints.query.initiate())

expect('request' in _meta! && 'response' in _meta!).toBe(true)

_meta = undefined
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/src/query/tests/devWarnings.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ If you have multiple apis, you *have* to specify the reducerPath option when usi
describe('`console.error` on unhandled errors during `initiate`', () => {
test('error thrown in `baseQuery`', async () => {
const api = createApi({
baseQuery() {
baseQuery(): { data: any } {
throw new Error('this was kinda expected')
},
endpoints: (build) => ({
Expand Down
2 changes: 1 addition & 1 deletion packages/toolkit/src/query/tests/unionTypes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ describe.skip('TS only tests', () => {
const useQueryStateWithSelectFromResult = api.endpoints.test.useQueryState(
undefined,
{
selectFromResult: () => true,
selectFromResult: () => ({ x: true }),
}
)

Expand Down
Loading

0 comments on commit 64a30d8

Please sign in to comment.