diff --git a/typescript/core/base.ts b/typescript/core/base.ts index 79dc317af..e681f2ac4 100644 --- a/typescript/core/base.ts +++ b/typescript/core/base.ts @@ -177,7 +177,8 @@ export interface _base { functions: (object: object) => string[]; - extend: (object: object, ...sources: any[]) => object; + extend(object: T): T; + extend(object: T, ...sources: U[]): T & UnionToIntersection; defaults: (object: object, ...sources: any[]) => object; @@ -399,3 +400,11 @@ type merge = { deepExtend(object: any, ...otherArgs: any[]): any; } + +type UnionToIntersection = ( + Union extends unknown + ? (x: Union) => void + : never +) extends ((x: infer Intersection) => void) + ? Intersection + : never;