I'm trying to dynamically generate a type based on the key(s) of an existing type.
interface A {
X: number
}
type S = keyof A // correct "X"
type V = A[S] // correct: number
type B = {
[S]: A[S] // Error: A computed property name in a type literal must refer to an
// expression whose type is a literal type or a 'unique symbol' type.
}
What is the correct way to generate a type with dynamic properties based on the key of another type?
Bwhich will be exactly the same asA? What is the point of that?{[K in keyof T]: {get(this: {[S in typeof key]: number}): T[K]}}I just tried to simplify to the part I was having trouble with so the question was concise and answerable.