|
1 | 1 | /*eslint-disable react/prop-types*/ |
2 | 2 |
|
3 | 3 | import React, { Component } from 'react' |
4 | | -import { createStore, applyMiddleware } from 'redux' |
| 4 | +import { createStore, applyMiddleware, UnknownAction, Action } from 'redux' |
5 | 5 | import { Provider as ProviderMock, connect } from '../../src/index' |
6 | 6 | import * as rtl from '@testing-library/react' |
7 | 7 | import '@testing-library/jest-dom/extend-expect' |
@@ -2278,9 +2278,7 @@ describe('React', () => { |
2278 | 2278 | interface Store2State1Type { |
2279 | 2279 | second: string |
2280 | 2280 | } |
2281 | | - interface ActionType { |
2282 | | - type: string |
2283 | | - } |
| 2281 | + type ActionType = UnknownAction |
2284 | 2282 | type NoDispatchType = {} |
2285 | 2283 | const c3Spy = jest.fn() |
2286 | 2284 | const c2Spy = jest.fn() |
@@ -2414,9 +2412,7 @@ describe('React', () => { |
2414 | 2412 |
|
2415 | 2413 | it('should subscribe properly when a new store is provided via props', () => { |
2416 | 2414 | type RootStateType = number |
2417 | | - interface ActionType { |
2418 | | - type: string |
2419 | | - } |
| 2415 | + type ActionType = UnknownAction |
2420 | 2416 | const store1 = createStore( |
2421 | 2417 | (state: RootStateType = 0, action: ActionType) => |
2422 | 2418 | action.type === 'INC' ? state + 1 : state |
@@ -2822,7 +2818,7 @@ describe('React', () => { |
2822 | 2818 | ) |
2823 | 2819 | return null |
2824 | 2820 | //@ts-ignore before typescript4.0, a catch could not have type annotations |
2825 | | - } catch (error) { |
| 2821 | + } catch (error: any) { |
2826 | 2822 | return error.message |
2827 | 2823 | } finally { |
2828 | 2824 | spy.mockRestore() |
@@ -3129,15 +3125,16 @@ describe('React', () => { |
3129 | 3125 | it('should use the latest props when updated between actions', () => { |
3130 | 3126 | type RootStateType = number |
3131 | 3127 | type PayloadType = () => void |
3132 | | - interface ActionType { |
3133 | | - type: string |
| 3128 | + interface ActionType extends Action<string> { |
3134 | 3129 | payload?: PayloadType |
3135 | 3130 | } |
| 3131 | + |
3136 | 3132 | const reactCallbackMiddleware = (store: MiddlewareAPI) => { |
3137 | 3133 | let callback: () => void |
3138 | 3134 |
|
3139 | | - return (next: ReduxDispatch) => (action: ActionType) => { |
| 3135 | + return (next: ReduxDispatch) => (action: UnknownAction) => { |
3140 | 3136 | if (action.type === 'SET_COMPONENT_CALLBACK') { |
| 3137 | + // @ts-ignore |
3141 | 3138 | callback = action.payload! |
3142 | 3139 | } |
3143 | 3140 |
|
@@ -3171,7 +3168,9 @@ describe('React', () => { |
3171 | 3168 |
|
3172 | 3169 | const store = createStore( |
3173 | 3170 | counter, |
3174 | | - applyMiddleware(reactCallbackMiddleware) |
| 3171 | + applyMiddleware |
| 3172 | + // @ts-ignore |
| 3173 | + (reactCallbackMiddleware) |
3175 | 3174 | ) |
3176 | 3175 |
|
3177 | 3176 | interface ChildrenTStatePropsType { |
|
0 commit comments