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
As each instances are defined as branded type of the extended enum (#7), type guards should be supported.
enum_Fruit{Apple,Orange}classFruitextendsextend<typeof_Fruit,_Fruit>(_Fruit){}declareconstf: Fruit;if(f===Fruit.Apple){typeT=typeoff;// should be Fruit.Apple, it is not working now regardless of type guards}if(f.is(Fruit.Apple)){typeT=typeoff;// Fruit.Apple}if(f.is.not(fruit.Apple)){typeT=typeoff;// Exclude<F, Fruit.Apple> or something similar}
The text was updated successfully, but these errors were encountered:
Apparently, type guards by nested property is not supported in current version of TypeScript. (related pull request - microsoft/TypeScript#38839)
Therefore, providing a type guard for is.not is not possible right now.
We propose an alternative to use isNot as an alias of is.not. isNot lives as a direct property of ExtendedEnum, hence it can be used for type narrowing.
is.not will continue to be supported, but type guards will not be provided.
As each instances are defined as branded type of the extended enum (#7), type guards should be supported.
The text was updated successfully, but these errors were encountered: