很难找到信息,因为我不知道这叫做什么,只能从上下文中判断它在做什么。它在下面的例子中使用。
https://github.com/piotrwitek/react-redux-typescript-guide#typing-reducer
// inferring union type of actions
import { $call } from 'utility-types';
import * as actions from './actions';
const returnsOfActions = Object.values(actions).map($call);
export type TodosAction = typeof returnsOfActions[number];特别是最后一行。number中没有定义,但它似乎通过数组returnOfActions循环。基本上,这是否等同于
export type TodosAction = ActionType1 | ActionType2 | ...你会怎么称呼这种语法(这样我就能读得更多了)
发布于 2018-03-18 12:00:54
我也对这个语法感兴趣。原来这就是你所说的查找类型。这是最好的解释在annoucement博客的类型2.1这里。
在您的例子中,如果我们显式地写出类型,则更容易理解,
ActionType1 | ActionType2
导出类型TodosAction =returnsOfActionsnumber类型;https://stackoverflow.com/questions/49329658
复制相似问题