![](/img/trans.png)
[英]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.