[英]What does ?: mean in TypeScript?
I found the following in a TypeScript declaration file for Angular:我在 Angular 的 TypeScript 声明文件中找到以下内容:
interface IDirective{
compile?:
(templateElement: IAugmentedJQuery,
What does the ?:
after compile do?编译后的
?:
是做什么的?
See: Walkthrough: Interfaces | 请参阅: 演练:接口| TypeScript :: Describing Simple Types .
TypeScript ::描述简单类型 。
Basically, ?
基本上,
?
marks the member as being optional in the interface. 将成员标记为接口中的可选项。
(EDIT: As noted in comments, this is not restricted to interfaces.) (编辑:正如评论中所述,这不仅限于接口。)
In this case, the ?:
is not a single operator, but rather two operators: 在这种情况下,
?:
不是单个运算符,而是两个运算符:
?
(optional), (可选的),
:
(specify type). :
指定类型)。
In other languages/cases, ?:
would be the Elvis Operator . 在其他语言/案例中,
?:
将是猫王运营商 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.