Redux & flow-typed で mapStateToProps に型を付ける

メモ。

Reduxで開発中、 flow-typedを導入し、チェックしたところ下記のエラーが。

export default connect(mapStateToProps)(Metadata);
                    ^^^^^^^^^^^^^^^^^^^^^^^^ function call. Could not decide which case to select

MapStateToProps のtypeが用意されているのでそれを使う。

import type { MapStateToProps } from "react-redux"

const mapStateToProps: MapStateToProps<*, *, *> = (state: StateType) => {
  return ...
}

export default connect(mapStateToProps)(...)

参考: react-redux type error when only passing in only mapStateToProps on flow v0.55.0 #1269