Использование потока в проекте React Redux - PullRequest
2 голосов
/ 20 июня 2020

У меня возникают неприятные проблемы при попытке применить тип для функции подключения. Не уверен, что поток реализован правильно. Я применил ту же реализацию к двум отдельным файлам JS, один в порядке, но другой продолжает вызывать такие ошибки

1. all branches are incompatible: Either  null [1] is incompatible with  function type [2]. Or  null [1] is incompatible with  function type [3].Flow(InferError)

2. a call signature declaring the expected parameter / return type is missing in  `ReduxDispatchProps` [1] but exists in  function type [2] in the return value.Flow(InferError)

кстати, вот моя реализация.

interface ReactProps {
  user?: User;
  asset?: Asset;
  autoUpdate?: boolean;
  std_time?: number;
  handleOpenModalUpdateStandardTime?: (standardTime: StandardTime) => void;
}

interface ReduxStateProps {}

interface ReduxDispatchProps {
  updateEntityStandardTime: UpdateEntityStandardTimeHandler;
}

interface IProps extends ReduxStateProps, ReactProps, ReduxDispatchProps {}

class ComponentA extends Component<IProps,{}> {}

const mapDispatchToProps = (dispatch): ReduxDispatchProps => {
  return {
    updateEntityStandardTime: (payload: StandardTime, callback: ?Callback) =>
      dispatch(updateEntityStandardTimeRequest(payload, callback)),
  };
};

export default connect<IProps, ReactProps, _, _, _, _>(
  null,
  mapDispatchToProps
)(ComponentA);

Жду помощи от вас, ребята!

...