ant-design/components/_util/extendsObject.ts
Wuxh 951e0e2c79
fix(list): fix error reported due to incorrect paginator parameters (#39681)
* fix(list): fix pagination parameter error

* test: add case

* test: update snapshot

* chore: update case

* feat(util): add mergeProps

ref: 3c87f1c5b1/src/utils/with-default-props.tsx (L5)

* chore: replace method

* chore: rename
2022-12-24 15:05:33 +08:00

22 lines
444 B
TypeScript

type RecordType = Record<string, any>;
function extendsObject<T extends RecordType>(...list: T[]) {
const result: RecordType = { ...list[0] };
for (let i = 1; i < list.length; i++) {
const obj = list[i];
if (obj) {
Object.keys(obj).forEach((key) => {
const val = obj[key];
if (val !== undefined) {
result[key] = val;
}
});
}
}
return result;
}
export default extendsObject;