Created
August 11, 2022 16:34
-
-
Save DonHuskini/10148dbe6cc4987504a4281fdcf49c44 to your computer and use it in GitHub Desktop.
Object keys from array values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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