UNPKG

@tienedev/datype

Version:

Modern TypeScript utility library with pragmatic typing and zero dependencies

18 lines 732 B
/** * Creates a new object with only the specified keys from the source object. * Provides perfect TypeScript type inference for the resulting object. * * @param obj - The source object to pick from * @param keys - Array of keys to pick from the source object * @returns A new object containing only the specified keys * * @example * ```typescript * const user = { id: 1, name: 'John', email: 'john@example.com', age: 30 }; * const basicInfo = pick(user, ['id', 'name']); * // Result: { id: 1, name: 'John' } * // Type: { id: number; name: string } * ``` */ export declare function pick<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: readonly K[]): Pick<T, K>; //# sourceMappingURL=index.d.ts.map