Converting object to union type
07:50 20 Apr 2019

I have a question for typescript. I want to create somemething like union from a object values. How I can achieve this? eg:

const x = {
    x: 1,
    y: 2,
    z: 'a string',
    k: document.createElement('div')
}

const y = (y: the value which exist of x ): boolean => {
  return true
}

Something like:

type ValueOf = T[keyof T]; 

but for objects. Any hints are welcome.

typescript typescript-typings