【问题标题】:What is the meaning of bitwise "OR" operator for interfaces [duplicate]接口的按位“或”运算符是什么意思[重复]
【发布时间】:2020-05-26 15:56:41
【问题描述】:

我见过用于 Typescript 接口的按位运算符。谁能在这里描述它的含义:

interface RowGroup {
  __metaData: RowGroupMetaData;
}

interface RowData {
  id: number;
  task: string;
  complete: number;
  priority: string;
  issueType: string;
}

type GridRow = RowGroup | RowData;  //**** THIS LINE

【问题讨论】:

  • 不是按位或,而是union type
  • 据我记得这是一个联合。这意味着在函数中传递 GridRow 的对象时,它可以是 RowGroup 也可以是 RowData

标签: javascript typescript


【解决方案1】:

这不是按位或,而是联合类型。从文档中阅读this

用简单的英语,您可以说GridRow 类型是RowGroupRowData 类型。

【讨论】:

    猜你喜欢
    • 2015-06-23
    • 1970-01-01
    • 2013-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-19
    • 2013-05-07
    • 2015-09-18
    相关资源
    最近更新 更多