Skip to content

Commit

Permalink
use native Pick utility type function
Browse files Browse the repository at this point in the history
  • Loading branch information
Harris-Miller committed Oct 2, 2023
1 parent 1380b1a commit fede08f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions types/pick.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ElementOf } from './util/tools';

export function pick<const Names extends readonly [PropertyKey, ...PropertyKey[]]>(names: Names): <U extends Record<ElementOf<Names>, any>>(obj: U) => string extends keyof U ? Record<string, U[keyof U]> : { [P in ElementOf<Names>]: U[P] };
export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : { [P in ElementOf<Names>]: U[P] };
export function pick<const Names extends readonly [PropertyKey, ...PropertyKey[]]>(names: Names): <U extends Record<ElementOf<Names>, any>>(obj: U) => string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;
export function pick<U, const Names extends readonly [keyof U, ...(keyof U)[]]>(names: Names, obj: U): string extends keyof U ? Record<string, U[keyof U]> : Pick<U, ElementOf<Names>>;

0 comments on commit fede08f

Please sign in to comment.