types(Picker): use tsx (#8137)

This commit is contained in:
neverland
2021-02-12 12:07:22 +08:00
committed by GitHub
parent 76aaba8089
commit 7355b610e1
7 changed files with 144 additions and 90 deletions
+3 -3
View File
@@ -1,12 +1,12 @@
import { deepAssign } from './deep-assign';
export function deepClone(obj: Record<string, any>): Record<string, any> {
export function deepClone<T extends Record<string, any>>(obj: T): T {
if (Array.isArray(obj)) {
return obj.map((item) => deepClone(item));
return (obj.map((item) => deepClone(item)) as unknown) as T;
}
if (typeof obj === 'object') {
return deepAssign({}, obj);
return deepAssign({}, obj) as T;
}
return obj;