mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 17:44:35 +08:00
20 lines
577 B
TypeScript
20 lines
577 B
TypeScript
// copied https://github.com/ant-design/ant-design-mobile/blob/d3b3bae/src/utils/with-default-props.tsx
|
|
function mergeProps<A, B>(a: A, b: B): B & A;
|
|
function mergeProps<A, B, C>(a: A, b: B, c: C): C & B & A;
|
|
function mergeProps<A, B, C, D>(a: A, b: B, c: C, d: D): D & C & B & A;
|
|
function mergeProps(...items: any[]) {
|
|
const ret: any = {};
|
|
items.forEach((item) => {
|
|
if (item) {
|
|
Object.keys(item).forEach((key) => {
|
|
if (item[key] !== undefined) {
|
|
ret[key] = item[key];
|
|
}
|
|
});
|
|
}
|
|
});
|
|
return ret;
|
|
}
|
|
|
|
export default mergeProps;
|