types(Uploader): use tsx (#8192)

This commit is contained in:
neverland
2021-02-21 17:04:56 +08:00
committed by GitHub
parent da09a6d871
commit 4c0120a183
6 changed files with 120 additions and 72 deletions
+8 -2
View File
@@ -38,9 +38,15 @@ export function get(object: any, path: string): any {
return result;
}
export function pick<T, U extends keyof T>(obj: T, keys: ReadonlyArray<U>) {
export function pick<T, U extends keyof T>(
obj: T,
keys: ReadonlyArray<U>,
ignoreUndefined?: boolean
) {
return keys.reduce((ret, key) => {
ret[key] = obj[key];
if (!ignoreUndefined || obj[key] !== undefined) {
ret[key] = obj[key];
}
return ret;
}, {} as Pick<T, U>);
}