Есть ли способ обеспечить структуру типа при сочетании с любым?
Вот пример, который я имею в виду:
function foo<T extends object>(obj: T): { type: 'FooBar' } & T {
return { type: 'FooBar', ...obj };
}
const bar = foo({bar: 'foo'} as any); // expecting bar type to be {type: 'FooBar'; [x: string]: any;} not any
Playground Link