cal/packages/types/utils.d.ts
Alex van Andel 87d4afea13
Same-day schedules created invalid workingHours (#3742)
* Same-day schedules created invalid workingHours

* Uncomment logger

* Previous version did not properly substract the days

Co-authored-by: Leo Giovanetti <hello@leog.me>
2022-08-08 14:17:33 -06:00

18 lines
634 B
TypeScript

/** Makes selected props from a record non optional */
export type Ensure<T, K extends keyof T> = Omit<T, K> & {
[EK in K]-?: NonNullable<T[EK]>;
};
/** Makes selected props from a record optional */
export type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
/** Get the union type of all the values in an object, array or array-like type `T` */
export type ValuesType<T extends ReadonlyArray<unknown> | ArrayLike<unknown> | Record<unknown, unknown>> =
T extends ReadonlyArray<unknown>
? T[number]
: T extends ArrayLike<unknown>
? T[number]
: T extends object
? T[keyof T]
: never;