Skip to content

Instantly share code, notes, and snippets.

@bsitruk
Created June 8, 2022 07:36
Show Gist options
  • Save bsitruk/84aea0f919a967194fe3dae540f1a911 to your computer and use it in GitHub Desktop.
Save bsitruk/84aea0f919a967194fe3dae540f1a911 to your computer and use it in GitHub Desktop.
const keys = ['k1', 'k2', 'k3']
const Keys = typeof keys[number]
type Object = {
k1: number,
k2: boolean
}
type KeyValue = {
[k in Keys]: k extends keyof Object ? Object[k] : unknown
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment