types(utils): pick type (#8179)
This commit is contained in:
+2
-2
@@ -38,9 +38,9 @@ export function get(object: any, path: string): any {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function pick(obj: Record<string, any>, keys: string[]) {
|
||||
export function pick<T, U extends keyof T>(obj: T, keys: ReadonlyArray<U>) {
|
||||
return keys.reduce((ret, key) => {
|
||||
ret[key] = obj[key];
|
||||
return ret;
|
||||
}, {} as Record<string, any>);
|
||||
}, {} as Pick<T, U>);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user