[英]What does the | (pipe) mean at the start of a type in TypeScript
interface MyInterface {
someConst:
| {
fullName: string
email: string
}
| null
| undefined
}
我的 tslint(我的 linter)添加了第一个| 为我而来。
我知道第二和第三 | 是联合类型,但第一个是什么? 在这里做什么?
这基本上是 tslint 使代码更易于阅读,它对类型无关紧要,应该被忽略,应该有一个 tslint 规则可以调整 - 如果我可以访问它,也许我可以提供帮助。
它是可选的,它根本不做任何事情。 如果你把你的 tslint 发给我,我可能会看看它并尝试找到规则。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.