seasonedcc / composable-functions

Types and functions to make composition easy and safe
MIT License
665 stars 14 forks source link

Fix MergeObjs type to behave more like JS's Object.assign and add som… #68

Closed gustavoguichard closed 1 year ago

gustavoguichard commented 1 year ago

…e regression tests.

Reasoning

There was a mismatch between type and runtime behavior of mergeObjects as shown here:

const a = { a: 1, b: 2 }
const b = { b: true }
const c = mergeObjects([a, b]) // should behave like { ...a, ...b }
//    ˆ?  { a: number, b: never }

This PR fixes it according to what we would expect: { a: number, b: boolean }. It also enforces the correct parameter types with TS: DomainFunction<string, unknown>[]

This bug was mentioned in #66