Here is my array:
const a = ['one', 'two'] as const;
Here is the type of object I'm working with:
type T = {
{ [key in typeof a[number]]: number;
}
The expected result should look like this:
const r: T = {
one: 0,
two: 0
}
However, when I tried to use a map function, it didn't work:
const z: T = a.map((prop) => [prop, 0]);
Instead of the desired output, I received an error message saying: Type '(number | "one" | "two")[][]' is missing the following properties from type 'T': one, two(2739)