From DefinitelyTyped:
export type CSSProperties = & ObservableProperties & ObservableProperties;
Every description of ampersand that I can find says that it is an intersection operator. In which case, what does the first ampersand mean?
References:
What does the ampersand (&) mean in a TypeScript type definition?
Official doc
Typescript Deep Dive
Leading ampersand is ignored by the current version of the compiler, pretty much in the same way as the last ;
is ignored inside interface declaration:
interface a {
a(): string;
}
type b = & a;
TypeScript playground says type b = a
The typings linked from the question are (ab)using this feature to have more uniform syntax for intersection types:
export type CSSProperties =
& ObservableProperties<csstype.Properties>
& ObservableProperties<csstype.PropertiesHyphen>;
When written this way, when you remove the first intersection member for example, you can just delete the whole line and you don't have to change anything else.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With