Skip to content
Merged
11 changes: 7 additions & 4 deletions types/ramda/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
declare let R: R.Static;

declare namespace R {
type Diff<T extends string, U extends string> = ({[P in T]: P } & {[P in U]: never } & { [x: string]: never })[T];
type Omit<T, K extends string> = Pick<T, Diff<keyof T, K>>;

type Ord = number | string | boolean;

type Path = ReadonlyArray<(number | string)>;
Expand Down Expand Up @@ -1174,8 +1177,8 @@ declare namespace R {
/**
* Returns a partial copy of an object omitting the keys specified.
*/
omit<T>(names: ReadonlyArray<string>, obj: T): T;
omit(names: ReadonlyArray<string>): <T>(obj: T) => T;
omit<T, K extends string>(names: ReadonlyArray<K>, obj: T): Omit<T, K>;
omit<K extends string>(names: ReadonlyArray<K>): <T>(obj: T) => Omit<T, K>;

/**
* Accepts a function fn and returns a function that guards invocation of fn such that fn can only ever be
Expand Down Expand Up @@ -1285,8 +1288,8 @@ declare namespace R {
* Returns a partial copy of an object containing only the keys specified. If the key does not exist, the
* property is ignored.
*/
pick<T, K extends keyof T>(names: ReadonlyArray<K | string>, obj: T): Pick<T, K>;
pick(names: ReadonlyArray<string>): <T, U>(obj: T) => U;
pick<T, K extends string>(names: ReadonlyArray<K>, obj: T): Pick<T, Diff<keyof T, keyof Omit<T, K>>>;
pick<K extends string>(names: ReadonlyArray<K>): <T>(obj: T) => Pick<T, Diff<keyof T, keyof Omit<T, K>>>;

/**
* Similar to `pick` except that this one includes a `key: undefined` pair for properties that don't exist.
Expand Down