Creates an EnumTypeGuard that checks that the value is a valid enum value.
EnumTypeGuard
The enum type
The enum object to create a guard for
A type guard for values of T (T[keyof T])
T
T[keyof T]
enum Direction { up = 0, down = 1, left = 2, right = 3,}const isDirection = isEnum(Direction);isDirection(Direction.up); // trueisDirection(2); // trueisDirection("hello"); // false Copy
enum Direction { up = 0, down = 1, left = 2, right = 3,}const isDirection = isEnum(Direction);isDirection(Direction.up); // trueisDirection(2); // trueisDirection("hello"); // false
Creates an
EnumTypeGuardthat checks that the value is a valid enum value.