I saw a typescript code like
type Point = PartialPointX & { y: number; };
and I know '&' in javascript is "and",'|' is "OR", do they work different in typescript?
I saw a typescript code like
type Point = PartialPointX & { y: number; };
and I know '&' in javascript is "and",'|' is "OR", do they work different in typescript?
That is an intersection type. Basically it combines multiple types into one so your new type Point
is an object with the properties of PartialPointX
and { y: number; }
.