Is there a way to ensure type structure when combining with any?
Here is an example what I have in mind:
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