Skip to content

Commit

Permalink
fix propIs
Browse files Browse the repository at this point in the history
  • Loading branch information
KiaraGrouwstra committed Nov 29, 2016
1 parent 1f852ac commit 046521d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
3 changes: 2 additions & 1 deletion ramda-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
});

(() => {
Expand Down
16 changes: 7 additions & 9 deletions ramda.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T, V, K extends keyof V>(type: T, name: K, obj: V): obj is (V & Record<K, T>)
// v object info not available in time :(
// propIs<T, V, K extends keyof V>(type: T, name: K): (obj: V) => obj is (V & Record<K, T>)
// propIs<T, V, K extends keyof V>(type: T): {
// (name: K, obj: V): obj is (V & Record<K, T>);
// (name: K): (obj: V) => obj is (V & Record<K, T>);
// }
propIs(type: any, name: Prop): (obj: any) => boolean;
propIs(type: any): CurriedFunction2<Prop, any, boolean>;
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<T, V, K extends keyof V, R extends V[K]>(type: T, name: K, obj: V): R is T;
// propIs<T, V, K extends keyof V, R extends V[K]>(type: T, name: K): (obj: V) => R is T;
// propIs<T, V, K extends keyof V, R extends V[K]>(type: T): CurriedFunction2<K, V, R is T>;
// propIs<T, V, K extends keyof V, R extends V[K]>(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.
Expand Down

0 comments on commit 046521d

Please sign in to comment.