谷歌搜索只会返回与按位运算符的数字应用程序相关的结果,所以我想在SO上询问它。我正在阅读@ngrx文档,我看到了这段代码:
export class Increment implements Action {
readonly type = CounterActionTypes.INCREMENT;
}
export class Decrement implements Action {
readonly type = CounterActionTypes.DECREMENT;
}
export class Reset implements Action {
readonly type = CounterActionTypes.RESET;
constructor(public payload: number) {}
}
export type CounterActionsUnion = Increment | Decrement | Reset;
我的困惑在于使用类之间的按位OR - 如果这个问题听起来很少,我很抱歉,但为什么Increment | Decrement | Reset
表示这三个类的联合?谢谢!
在此问题的第2条评论中归功于@CRice。我只是为了方便而张贴它,因为他/她没有。
|字符,当在打字稿中使用时表示union type