interface inter<A extends string, B extends string> {
a: A
b: B
}
function ato<A extends string, B extends string>(...p: Array<inter<A, B>>): {[K in A]: B} {
return {} as {[K in A]: B}
}
const result = ato({
a: 'a0',
b: 'b0'
}, {
a: 'a1',
b: 'b1'
}
)
Type of result
is
{
a0: "b0" | "b1"
a1: "b0" | "b1"
}
I want to change the return type to:
{
a0: 'b0'
a1: 'b1'
}
Do you get it what I want?
Something like {[K in A]: V in B}
but this syntax is invalid.
Is it possible in TypeScript?