什么是| (管道)表示在 TypeScript 中类型的开头

What does the | (pipe) mean at the start of a type in TypeScript

interface MyInterface {     
    someConst:
    | {
        fullName: string
        email: string
      }
    | null
    | undefined
}

我的 tslint(我的 linter)添加了 first |为我而来。

我知道第二个和第三个|是联合类型,但第一个 | 是什么?在这里做什么?

它是可选的,它根本不做任何事情。如果你把你的 tslint 发给我,我可能会看一下并尝试找到规则。

这基本上是 tslint 使代码更易于阅读,它对类型无关紧要,应该被忽略,应该有一个你可以调整的 tslint 规则 - 如果我可以访问它,也许我可以提供帮助。