[英]What does the ampersand (&) mean in a TypeScript type definition?
[英]What does a prefixing “&” mean in a Typescript type definition?
来自DefinitelyTyped :
export type CSSProperties =&ObservableProperties&ObservableProperties;
我能找到的每个&符号都说它是一个交叉算子。 在哪种情况下,第一个&符是什么意思?
参考文献:
当前版本的编译器会忽略前导符号,几乎与上一版本相同;
在接口声明中被忽略:
interface a {
a(): string;
}
type b = & a;
TypeScript playground表示type b = a
从问题链接的类型是(ab)使用此功能为交集类型提供更统一的语法:
export type CSSProperties =
& ObservableProperties<csstype.Properties>
& ObservableProperties<csstype.PropertiesHyphen>;
以这种方式编写时,例如,当您删除第一个交叉点成员时,您可以删除整行,而不必更改任何其他内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.