Skip to content

Commit 411de28

Browse files
committed
Fix test TS errors
1 parent ee53e2b commit 411de28

File tree

4 files changed

+18
-20
lines changed

4 files changed

+18
-20
lines changed

test/components/connect.spec.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*eslint-disable react/prop-types*/
22

33
import React, { Component } from 'react'
4-
import { createStore, applyMiddleware } from 'redux'
4+
import { createStore, applyMiddleware, UnknownAction, Action } from 'redux'
55
import { Provider as ProviderMock, connect } from '../../src/index'
66
import * as rtl from '@testing-library/react'
77
import '@testing-library/jest-dom/extend-expect'
@@ -2278,9 +2278,7 @@ describe('React', () => {
22782278
interface Store2State1Type {
22792279
second: string
22802280
}
2281-
interface ActionType {
2282-
type: string
2283-
}
2281+
type ActionType = UnknownAction
22842282
type NoDispatchType = {}
22852283
const c3Spy = jest.fn()
22862284
const c2Spy = jest.fn()
@@ -2414,9 +2412,7 @@ describe('React', () => {
24142412

24152413
it('should subscribe properly when a new store is provided via props', () => {
24162414
type RootStateType = number
2417-
interface ActionType {
2418-
type: string
2419-
}
2415+
type ActionType = UnknownAction
24202416
const store1 = createStore(
24212417
(state: RootStateType = 0, action: ActionType) =>
24222418
action.type === 'INC' ? state + 1 : state
@@ -2822,7 +2818,7 @@ describe('React', () => {
28222818
)
28232819
return null
28242820
//@ts-ignore before typescript4.0, a catch could not have type annotations
2825-
} catch (error) {
2821+
} catch (error: any) {
28262822
return error.message
28272823
} finally {
28282824
spy.mockRestore()
@@ -3129,15 +3125,16 @@ describe('React', () => {
31293125
it('should use the latest props when updated between actions', () => {
31303126
type RootStateType = number
31313127
type PayloadType = () => void
3132-
interface ActionType {
3133-
type: string
3128+
interface ActionType extends Action<string> {
31343129
payload?: PayloadType
31353130
}
3131+
31363132
const reactCallbackMiddleware = (store: MiddlewareAPI) => {
31373133
let callback: () => void
31383134

3139-
return (next: ReduxDispatch) => (action: ActionType) => {
3135+
return (next: ReduxDispatch) => (action: UnknownAction) => {
31403136
if (action.type === 'SET_COMPONENT_CALLBACK') {
3137+
// @ts-ignore
31413138
callback = action.payload!
31423139
}
31433140

@@ -3171,7 +3168,9 @@ describe('React', () => {
31713168

31723169
const store = createStore(
31733170
counter,
3174-
applyMiddleware(reactCallbackMiddleware)
3171+
applyMiddleware
3172+
// @ts-ignore
3173+
(reactCallbackMiddleware)
31753174
)
31763175

31773176
interface ChildrenTStatePropsType {

test/components/hooks.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('React', () => {
2020
}
2121
list: Array<number>
2222
}
23-
const store = createStore<RootStateType, AnyAction, unknown, unknown>(
23+
const store = createStore<RootStateType, AnyAction, {}, {}>(
2424
(state, action) => {
2525
let newState =
2626
state !== undefined

test/integration/server-rendering.spec.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,13 @@
1111
import React, { FunctionComponent } from 'react'
1212
import { renderToString } from 'react-dom/server'
1313
import { createStore } from 'redux'
14+
import type { PayloadAction } from '@reduxjs/toolkit'
1415
import { Provider, connect } from '../../src/index'
1516
import type { Dispatch, Store } from 'redux'
1617

1718
describe('React', () => {
1819
describe('server rendering', () => {
19-
interface ActionType {
20-
type: string
21-
payload: {
22-
greeting: string
23-
}
24-
}
20+
type ActionType = PayloadAction<{ greeting: string }>
2521
function greetingReducer(
2622
state = { greeting: 'Hello' },
2723
action: ActionType

test/react-native/batch-integration.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,10 @@ describe('React Native', () => {
276276

277277
const store = createStore(
278278
counter,
279-
applyMiddleware(reactCallbackMiddleware)
279+
applyMiddleware(
280+
// @ts-ignore
281+
reactCallbackMiddleware
282+
)
280283
)
281284

282285
interface ChildrenTStatePropsType {

0 commit comments

Comments
 (0)