mergician icon indicating copy to clipboard operation
mergician copied to clipboard

Add support for Inferring types

Open denchen opened this issue 7 months ago • 1 comments

First off, great library. My request is that mergician would infer the type of the object passed in, or at least allow a generic

From the types definition, I see this:

export function mergician(...objects: object[]): object;

So the result is always of type object. But it would be nice if we could do this:

const obj1: MyType = { ... };
const obj2: Partial<MyType> = { ... };
const newObject1 = mergician(obj1, obj2); // newObject1 is now of type MyType

const newObject2 = mergician<MyType>({}, obj1); // newObject2 is cast as MyType

denchen avatar Jul 14 '24 06:07 denchen