首页 > 解决方案 > 使用 Redux 存储进行流类型检查是如何工作的?

问题描述

我见过这样的代码:

import type { Store as ReduxStore } from 'redux';

export type Store = ReduxStore<State, Action>;

我不明白<State, Action>在做什么。是否将类型参数传递给 ReduxStore?

标签: javascriptreduxflowtype

解决方案


是的,它们是类型参数。

export type Store = ReduxStore<State, Action>;

这表示类型Store是一种ReduxStore在任何特定时刻都具有类型状态的类型State,并且它减少了类型的过度动作Action

https://github.com/flowtype/flow-typed/blob/41297ff31698506c0b398507101615e687bc9e54/definitions/npm/redux_v3.xx/flow_v0.55.x-/redux_v3.xxjs#L19-L24


推荐阅读