ValueOf

Extract the union of all value types from an object type.

#types #typescript #utility-type
export type ValueOf<T> = T[keyof T];
// Usage
type Config = { theme: 'light' | 'dark'; size: number };
type ConfigValue = ValueOf<Config>;
// 'light' | 'dark' | number

Share this snippet

Comments