ant-design/components/_util/extendsObject.ts
flyflydogdog eaeb75eb44
chore: type refactor (#46346)
* type: type refactor

* chore: fix type WrapProps

* chore: remove generic of Component

---------

Co-authored-by: 张宁宁 <zhangnn1@yonghui.cn>
2023-12-09 13:31:45 +08:00

22 lines
460 B
TypeScript

import type { AnyObject } from './type';
const extendsObject = <T extends AnyObject = AnyObject>(...list: T[]) => {
const result: AnyObject = { ...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;