Skip to content

Instantly share code, notes, and snippets.

@ProdigySim
Created January 15, 2019 04:53
Show Gist options
  • Select an option

  • Save ProdigySim/c3ecefb6f5738a5cd0052373f293f7f0 to your computer and use it in GitHub Desktop.

Select an option

Save ProdigySim/c3ecefb6f5738a5cd0052373f293f7f0 to your computer and use it in GitHub Desktop.
Tyescript Values macro
// Get the types of all properties of T:
type Values<T> = T[keyof T];
@ProdigySim
Copy link
Copy Markdown
Author

e.g.

const x = {
    a: 1,
    b: 'dog',
    c: [1, 2, 3]
};

type XValues = Values<typeof x>;
// type XValues = string | number | number[]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment