Type inference for .toObject
sykire opened this issue · comments
Rodrigo commented
From:
toObject(keySelector: (element: T) => any, elementSelector?: (element: T) => any): Object;
To:
toObject<TKey, TElement>(keySelector: (element: T) => TKey, elementSelector?: (element: T) => TElement): Record<TKey, TElement>;
Mihai Ciuraru commented
Thanks, I will fix this in the next version.
Rodrigo commented
I've forgot that keys can be only of PropertyKey, so TKey extends PropertyKey
is necessary.
toObject<TKey extends PropertyKey, TElement>( keySelector: (element: T) => TKey, elementSelector?: (element: T) => TElement): Record<TKey, TElement>;
Mihai Ciuraru commented
Fixed in version 4.0.0. Thanks for the suggestion.