如何为mapDispatchToProps添加正确的类型(typesafe-actions)

时间:2019-05-23 15:23:46

标签: reactjs typescript redux typesafe-actions

如何使用<plugin> <artifactId>maven-assembly-plugin</artifactId> <version>${maven.assembly.version}</version> <executions> </executions> <!-- added this configuration tag --> <configuration> <descriptors> <descriptor>src/assembly/distribution.xml</descriptor> </descriptors> <tarLongFileMode>posix</tarLongFileMode> <outputDirectory>${project.build.directory}</outputDirectory> <appendAssemblyId>false</appendAssemblyId> </configuration> mapDispatchToProps添加正确的键入?

typesafe-actions

问题:

interface ActionAsyncRequest {
  a: string;
  b: number;
}

interface ActionAsyncSuccess {
  a: number;
}

interface ActionAsyncFailure { }


const actionAsync = createAsyncAction(
  '@namespace/REQUEST',
  '@namespace/SUCCESS',
  '@namespace/FAILURE'
)<
  ActionAsyncRequest,
  ActionAsyncSuccess,
  ActionAsyncFailure
>();

interface DispatchProps {
  myFunction: ActionType<typeof actionAsync.request> // this row should be fixed
}
const mapDispatchToProps: DispatchProps = {
  myFunction: actionAsync.request, // issue arises here
};

更新:
我已经设法解决了。不知道这是否是一个完美的解决方案,但是它可行。

Type 'PayloadAC<"@namespace/REQUEST", ActionAsyncRequest>' is missing the following properties from type 'PayloadAction<"@namespace/REQUEST", ActionAsyncRequest>': type, payload

0 个答案:

没有答案