ReactiveX / IxJS

The Interactive Extensions for JavaScript
https://reactivex.io/IxJS/
MIT License
1.32k stars 73 forks source link

toMap keySelector type is incorrect #364

Closed berndfuhrmann closed 4 months ago

berndfuhrmann commented 4 months ago

IxJS version: 5.0.0

Code to reproduce:

import { toMap } from 'ix/iterable';
// ...
const data = [{ key:'alpha', value:true }];
toMap<{ key:string, value:boolean }, string, boolean>(data, { keySelector: (item) => item.key });

Expected behavior: Typescript should compile this code.

Actual behavior: While the code itself seems to work, Typescript complains: Type 'string' is not assignable to type 'boolean'.ts(2322)

Additional information: In https://github.com/ReactiveX/IxJS/blob/master/src/asynciterable/tomap.ts and https://github.com/ReactiveX/IxJS/blob/master/src/iterable/tomap.ts the return value of keySelector should be TKey (or sth similar) instead of TElement.