From 87acc5ab0355b4d4c06ccf1fe5ae0f38286be789 Mon Sep 17 00:00:00 2001 From: tycho01 Date: Tue, 28 Feb 2017 16:13:45 +0100 Subject: [PATCH] prevent missing key errors triggered for {} type This became an issue due to type degeneration from unresolved generics. Could consider reverting this after that one is resolved. --- index.d.ts | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/index.d.ts b/index.d.ts index 07eaa8c..9f1d6bf 100644 --- a/index.d.ts +++ b/index.d.ts @@ -2289,6 +2289,9 @@ declare namespace R { pick(names: List): (obj: T) => Pick; // pick: CurriedFunction2, T, Pick>; + pick(names: List, obj: T): Partial; + pick(names: List): (obj: T) => Partial; + // pick: CurriedFunction2, T, Partial>; /** * Similar to `pick` except that this one includes a `key: undefined` pair for properties that don't exist. @@ -2459,7 +2462,7 @@ declare namespace R { // prop: CurriedFunction2; // Record version, more curry-friendly - // prop>(p: K, obj: T): V; // uncurried doesn't add value + prop>(p: K, obj: T): V; // uncurried adds value only for {} from e.g. degeneration prop(p: K): >(obj: T) => V; // prop>: CurriedFunction2; @@ -2510,15 +2513,15 @@ declare namespace R { // } // propIs: CurriedFunction3)>; // obj is? name unavailable... - // // curry-friendlier fallback - // // propIs(type: Function, name: Prop, obj: Struct): boolean; - // propIs(type: Function, name: Prop): (obj: Struct) => boolean; - // propIs(type: Function): CurriedFunction2, boolean>; - // // propIs(type: Function): { - // // (name: Prop, obj: Struct): boolean; - // // (name: Prop): (obj: Struct) => boolean; - // // } - // // propIs: CurriedFunction3, boolean>; + // curry-friendlier fallback + propIs(type: Function, name: Prop, obj: Struct): boolean; + propIs(type: Function, name: Prop): (obj: Struct) => boolean; + propIs(type: Function): CurriedFunction2, boolean>; + // propIs(type: Function): { + // (name: Prop, obj: Struct): boolean; + // (name: Prop): (obj: Struct) => boolean; + // } + // propIs: CurriedFunction3, boolean>; // mixed: propIs(type: T): { @@ -2549,8 +2552,8 @@ declare namespace R { // propOr(val: T): (p: K) => (obj: U) => U[K]|T; // U too early? // propOr: CurriedFunction3; - // // presume the value at the given key matches the type of the default value, bad but less likely to fail with currying - // // propOr(val: T, p: Prop, obj: Struct): T; // don't think this adds value for the uncurried version + // presume the value at the given key matches the type of the default value, bad but less likely to fail with currying + propOr(val: T, p: Prop, obj: Struct): T; // adds value only to protect against {} from e.g. generic degeneration // propOr(val: T, p: Prop): (obj: Struct) => T; // // propOr(val: T): (p: Prop, obj: Struct) => T; // propOr(val: T): CurriedFunction2, T>;