Skip to content

Instantly share code, notes, and snippets.

@DonHuskini
Created August 11, 2022 16:34
Show Gist options
  • Save DonHuskini/10148dbe6cc4987504a4281fdcf49c44 to your computer and use it in GitHub Desktop.
Save DonHuskini/10148dbe6cc4987504a4281fdcf49c44 to your computer and use it in GitHub Desktop.
Object keys from array values
const pathIds = ["p1", "p2", "p3", "p4", "p5"] as const
function Fn() {
let data: { [K in typeof pathIds[number]]?: { x: number, y: number } } = {}
data['p1'] = {
x: 10,
y: 20
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment