Merge branch 'main' into new-admin

This commit is contained in:
baldo 2022-08-30 15:16:06 +02:00
commit 781cbca94e
3 changed files with 399 additions and 387 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]);
}