Server: Update typescript.

This commit is contained in:
baldo 2022-08-30 15:03:09 +02:00
parent ac8159ce1d
commit 94e35b0bb4
3 changed files with 8 additions and 6 deletions
server/shared/types

View file

@ -144,7 +144,9 @@ export function toIsArray<T>(isT: TypeGuard<T>): TypeGuard<T[]> {
return (arg): arg is T[] => isArray(arg, isT);
}
export function toIsEnum<E>(enumDef: E): EnumTypeGuard<E> {
export function toIsEnum<E extends Record<keyof E, ValueOf<E>>>(
enumDef: E
): EnumTypeGuard<E> {
return (arg): arg is ValueOf<E> =>
Object.values(enumDef).includes(arg as [keyof E]);
}