Would it by possible, in TypeScript, to create a function which will be used like this:
foo(
{ key1: 'hello' },
{ key2: 5 },
{ key3: true },
)
and it would return a type like below?
{
key1: string,
key2: number,
key3: boolean,
}
The function would ideally allow arbitrary number of arguments. This is something like an intersection of arbitrary number of types.
There is this question which asks for something similar, but they have the array of types declared as const
in a variable.
I suspect that what I suggest is not possible but looking forward to be surprised.