From 4718f2c45fb905911e4bcd9940ad0e99e40eb806 Mon Sep 17 00:00:00 2001 From: du Date: Thu, 22 Jul 2021 01:29:36 +0800 Subject: [PATCH] pref: kill ugly writing --- test/integration/dynamic-reducers.spec.tsx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/test/integration/dynamic-reducers.spec.tsx b/test/integration/dynamic-reducers.spec.tsx index 40602dd7b..16045449d 100644 --- a/test/integration/dynamic-reducers.spec.tsx +++ b/test/integration/dynamic-reducers.spec.tsx @@ -43,7 +43,9 @@ describe('React', () => { children: ReactNode reducers: ReducersType } - + interface ReduxContextType extends ReactReduxContextValue { + storeState?: any + } function ExtraReducersProvider({ children, reducers, @@ -53,13 +55,9 @@ describe('React', () => { {(injectReducers) => ( {(reduxContext) => { - interface ReduxContextType extends ReactReduxContextValue { - storeState?: any - } - const latestState = - reduxContext && reduxContext.store.getState() - const contextState = - reduxContext && (reduxContext as ReduxContextType).storeState + const latestState = reduxContext!.store.getState() + const contextState = (reduxContext as ReduxContextType) + .storeState let shouldInject = false let shouldPatch = false @@ -80,7 +78,7 @@ describe('React', () => { } if (shouldInject) { - injectReducers && injectReducers(reducers) + injectReducers!(reducers) } if (shouldPatch && reduxContext) { @@ -89,7 +87,7 @@ describe('React', () => { // this would better avoid tearing in a future concurrent world const patchedReduxContext = { ...reduxContext, - storeState: reduxContext && reduxContext.store.getState(), + storeState: reduxContext!.store.getState(), } return (