Ошибка типа при объединении реактивного проекта "React Toastify Redux" - PullRequest
0 голосов
/ 29 января 2020

Я пытаюсь добавить

https://www.npmjs.com/package/react-toastify-redux#toast -base-option

Когда я пытаюсь объединить сокращения, я получаю ошибка ниже

    No overload matches this call.
  Overload 1 of 2, '(reducers: ReducersMapObject<{ basketsReducer: Reducer<any, AnyAction>; toasts: Toast[]; }, any>): Reducer<{ basketsReducer: Reducer<any, AnyAction>; toasts: Toast[]; }, AnyAction>', gave the following error.
    Type '(toastList: Toast[], action: ToastAction<any>) => Toast[]' is not assignable to type 'Reducer<Toast[], any>'.
      Types of parameters 'toastList' and 'state' are incompatible.
        Type 'Toast[] | undefined' is not assignable to type 'Toast[]'.
          Type 'undefined' is not assignable to type 'Toast[]'.
  Overload 2 of 2, '(reducers: ReducersMapObject<{ basketsReducer: Reducer<any, AnyAction>; toasts: Toast[]; }, AnyAction>): Reducer<{ basketsReducer: Reducer<...>; toasts: Toast[]; }, AnyAction>', gave the following error.
    Type '(toastList: Toast[], action: ToastAction<any>) => Toast[]' is not assignable to type 'Reducer<Toast[], AnyAction>'.
      Types of parameters 'toastList' and 'state' are incompatible.
        Type 'Toast[] | undefined' is not assignable to type 'Toast[]'.
          Type 'undefined' is not assignable to type 'Toast[]'.ts(2769)
index.ts(7, 18): The expected type comes from property 'toasts' which is declared here on type 'ReducersMapObject<{ basketsReducer: Reducer<any, AnyAction>; toasts: Toast[]; }, any>'
index.ts(7, 18): The expected type comes from property 'toasts' which is declared here on type 'ReducersMapObject<{ basketsReducer: Reducer<any, AnyAction>; toasts: Toast[]; }, AnyAction>'

Могу ли я узнать, почему я получаю эту ошибку, другие мои редукторы работают нормально, могут найти фрагменты кода для моего комбайнового редуктора

import { toastsReducer as toasts } from 'react-toastify-redux';
import basketsReducer from './basketsReducer';

 export default combineReducers({
    basketsReducer,toasts
 })
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...