diff --git a/ramda-tests.ts b/ramda-tests.ts index 951a71e..d142cfe 100644 --- a/ramda-tests.ts +++ b/ramda-tests.ts @@ -34,7 +34,8 @@ class F2 { R.propIs(Number)('x', {x: 1, y: 2}); //=> true R.propIs(Number)('x')({x: 1, y: 2}); //=> true R.propIs(Number, 'x', {x: 'foo'}); //=> false - R.propIs(Number, 'x', {}); //=> false + // v errors with `Argument of type '"x"' is not assignable to parameter of type 'never'.`, because 'x' is not in `{}`. + // R.propIs(Number, 'x', {}); //=> false }); (() => { diff --git a/ramda.d.ts b/ramda.d.ts index f447132..df228ad 100644 --- a/ramda.d.ts +++ b/ramda.d.ts @@ -1278,21 +1278,19 @@ declare namespace R { /** * Returns true if the specified object property is of the given type; false otherwise. */ - propIs(type: any, name: Prop, obj: any): boolean; + propIs(type: T, name: K, obj: V): obj is (V & Record) + // v object info not available in time :( + // propIs(type: T, name: K): (obj: V) => obj is (V & Record) + // propIs(type: T): { + // (name: K, obj: V): obj is (V & Record); + // (name: K): (obj: V) => obj is (V & Record); + // } propIs(type: any, name: Prop): (obj: any) => boolean; propIs(type: any): CurriedFunction2; propIs(type: any): { (name: Prop, obj: any): boolean; (name: Prop): (obj: any) => boolean; } - // errors: can't seem to use ` is T` on an expression yet: https://github.com/Microsoft/TypeScript/issues/12549 - // propIs(type: T, name: K, obj: V): R is T; - // propIs(type: T, name: K): (obj: V) => R is T; - // propIs(type: T): CurriedFunction2; - // propIs(type: T): { - // (name: K, obj: V): R is T; - // (name: K): (obj: V) => R is T; - // } /** * If the given, non-null object has an own property with the specified name, returns the value of that property.