Extract the union type from the values of an interface in TypeScript

Viewed 18

I would like to have a type transformer which discards the keys of an interface and creates the union type of the value types of the interface. For instance here is an interface, Dog, and the extracted type DogProperties:

interface Dog {
  name: string
  birth: number
}

type DogProperties = ValueType<typeof dog> // DogProperties = string | number

How can I achieve the type transformer ValueType? I'm under the impression that it'll require using keyof, but I'm not sure how.

1 Answers
Related