es-toolkit
Version:
A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.
14 lines • 388 B
TypeScript
//#region src/types/ValueOf.d.ts
/**
* Creates a union of all value types in `T`. The value-side counterpart to `keyof`.
*
* @template T - The object type to read values from.
*
* @example
* const STATUS = { IDLE: 'idle', ERROR: 'error' } as const;
* type Status = ValueOf<typeof STATUS>;
* // => 'idle' | 'error'
*/
type ValueOf<T> = T[keyof T];
//#endregion
export { ValueOf };