Currently, You can’t extend enum in TypeScript
Another option is to use type:
enum Color1 {
Red = "Red",
Green = "Green"
}
enum Color2 {
Yellow = "Yellow",
Blue = "Blue"
}
define a new type named Colors :
type Colors = Color1 | Color2;
Then you can use it as below :
class AppComponent {
public color: Colors;
ngOnInit(): void {
const Colors = { ...Color2, ...Color1 };
this.color = Colors.Red; // Colors.Green or Colors.Yellow or Colors.Blue
}
}
Stackblitz Here (Angular)
Stackblitz Here (Typescript)