Typescript objects inheritance

typescript

join objects (like flow inheritance):
другие самплы
const A = { key: '', boo: '' };
const B = { key: '', foo: '' };

type TupleToIntersection<T extends any[]> =
    { [I in keyof T]: (x: T[I]) => void }[number] extends
    (x: infer I) => void ? I : never;

let AB: TupleToIntersection<[typeof A, typeof B]> = {
  key: '',
  foo: '',
  boo: ''
}

// got from https://coder-studio.ru/q-2420766/ob-yedineniye-universal-nogo-massiva-typescript#a_74202280

// declare global {
interface ObjectConstructor {
    assign<T extends {}, U extends any[]>(
        target: T, ...source: U
    ): T & TupleToIntersection<U>;
}
// }

// got from https://stackoverflow.com/questions/75657143/better-type-inference-for-object-assign

/// output:

/*

var A = { key: '', boo: '' };
var B = { key: '', foo: '' };
var AB = {
    key: '',
    foo: '',
    boo: ''
};

*/
(ваш голос учтен)

Прикрепить файл