0π
β
The β&β is an operator used for creating Intersection Types.
A intersection type is a type that contains attributes belonging to both types in the intersection.
type A = {
foo: string,
bar: number,
}
type B = {
baz: boolean,
foo: string,
}
type C = A & B;
// type C = { foo: string, bar: number, baz: boolean }
You can read more about it here:
https://www.typescriptlang.org/docs/handbook/unions-and-intersections.html#intersection-types
and here:
https://www.typescriptlang.org/docs/handbook/advanced-types.html#type-aliases
I hope I have helped!
0π
Itβs an intersection type, it allows combining multiple types into one.
For example:
interface A {
a: string;
}
interface B {
b: boolean;
}
type C = A & B;
const value: C = {
a: 'a',
b: true
};
Type C is a combination of the properties in A and B.
Check official documentation for additional reference:
https://www.typescriptlang.org/docs/handbook/unions-and-intersections.html#intersection-types
Source:stackexchange.com