/** * 选取对象中指定属性 */ export function pick(obj: T, keys: TKeys[]): Pick; export function pick(obj: T, keys: TKeys[]): T; export function pick(obj: T, keys: TKeys[]): Pick { if (!obj) return {} as Pick; return keys.reduce((acc, key) => { if (Object.prototype.hasOwnProperty.call(obj, key)) acc[key] = obj[key]; return acc; }, {} as Pick); }