Let's consider an example where we have a class called Summator:
export default class Summator {
constructor(private readonly firstArgument: number, private readonly secondArgument: number) {}
get sum() {
return this.firstArgument + this.secondArgument
}
}
If we use ConstructorParameters, we will get a tuple [firstArgument: number, secondArgument: number]. But how can we get an object instead of a tuple, like this:
{
firstArgument: number,
secondArgument: number
}
I attempted to achieve this using the following code:
[K in keyof ConstructorParameters<typeof Summator>]: ConstructorParameters<typeof Summator>[K]
However, the resulting object looks like this:
{
0: number,
1: number
}