Fixed "attr" typing

This commit is contained in:
Michaël Lemaire 2019-12-01 17:51:07 +01:00
parent c446fb7840
commit b3751ea3ec

View file

@ -107,7 +107,7 @@ export function pipe<IN extends any[], INT, R>(f1: (...args: IN) => INT, f2: (va
/**
* Attribute getter
*/
export function attr<K extends string>(name: K): <V, O extends Record<K, V>>(obj: O) => V {
export function attr<K extends string>(name: K): <O extends Record<K, O[K]>>(obj: O) => O[K] {
return obj => obj[name];
}