You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Section 5.3: Extending enums without custom enum implementation
enumSourceEnum{value1=<any>'value1',value2=<any>'value2'}enumAdditionToSourceEnum{value3=<any>'value3',value4=<any>'value4'}// we need this type for TypeScript to resolve the types correctlytypeTestEnumType=SourceEnum|AdditionToSourceEnum;// and we need this value "instance" to use valuesletTestEnum=Object.assign({},SourceEnum,AdditionToSourceEnum);// also works fine the TypeScript 2 feature// let TestEnum = { ...SourceEnum, ...AdditionToSourceEnum };console.log(TestEnum);functioncheck(test: TestEnumType){returntest===TestEnum.value2;}console.log(TestEnum.value1);console.log(TestEnum.value2===<any>'value2');console.log(check(TestEnum.value2));console.log(check(TestEnum.value3));/******** * Some how there have a bit error * Object.assign not support there * **********/