Реагировать на Redux Connect DefaultRootState - PullRequest
0 голосов
/ 22 апреля 2020

Я обновляюсь до последних версий машинописного текста / реагирования / редуктора, и я застрял при ошибке компиляции в функции соединения реактивного редукса:

Я напечатал свой rootReducer со следующим, предоставленным документацией реагирует на избыточность:

export type RootState = ReturnType<typeof rootReducer>

Тип RootState, отображаемый машинописным шрифтом:

const rootReducer: Reducer<CombinedState<{
    authedUser: User | null;
    loading: LoadingState;
    errors: ErrorState;
    ui: UiState;
    entities: EntitiesState;
    shoppingCart: ShoppingCart;
    router: RouterState<...>;
}>, AnyAction>

Функция подключения такова:

export default withRouter(
connect<MyStateProps, MyDispatchProps, MyOwnProps>(
    ({ authedUser, entities, router }: StoreState): MyStateProps => ({
        authedUser,
        currentCinema: getCurrentCinema(entities.cinemas),
        router
    }),
    (dispatch) => ({ dispatch })
)(
    ({ authedUser, currentCinema, router, history }: Props) => {
        ...

И ошибка:

  /Users/cyprien/projets/vad2/src/components/App/App.tsx
  TypeScript error in /Users/cyprien/projets/vad2/src/components/App/App.tsx(69,9):
  No overload matches this call.

  The last overload gave the following error.
  Argument of type '({ authedUser, entities, router }: CombinedState<{ authedUser: User | null; loading: LoadingState; errors: ErrorState; ui: UiState; entities: EntitiesState; shoppingCart: ShoppingCart; router: RouterState<...>; }>) => MyStateProps' is not assignable to parameter of type 'MapStateToPropsParam<MyStateProps, MyOwnProps, DefaultRootState>'.

  Type '({ authedUser, entities, router }: CombinedState<{ authedUser: User | null; loading: LoadingState; errors: ErrorState; ui: UiState; entities: EntitiesState; shoppingCart: ShoppingCart; router: RouterState<...>; }>) => MyStateProps' is not assignable to type 'MapStateToPropsFactory<MyStateProps, MyOwnProps, DefaultRootState>'.

    Types of parameters '__0' and 'initialState' are incompatible.
      Type 'DefaultRootState' is not assignable to type 'CombinedState<{ authedUser: User | null; loading: LoadingState; errors: ErrorState; ui: UiState; entities: EntitiesState; shoppingCart: ShoppingCart; router: RouterState<...>; }>'.

        Type 'DefaultRootState' is missing the following properties from type '{ authedUser: User | null; loading: LoadingState; errors: ErrorState; ui: UiState; entities: EntitiesState; shoppingCart: ShoppingCart; router: RouterState<...>; }': authedUser, loading, errors, ui, and 3 more.  TS2769

67 | export default withRouter(
68 |     connect<MyStateProps, MyDispatchProps, MyOwnProps>(
69 |         ({ authedUser, entities, router }: StoreState): MyStateProps => ({
   |         ^
70 |             authedUser,
71 |             currentCinema: getCurrentCinema(entities.cinemas),
72 |             router
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...