Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toMap keySelector type is incorrect #364

Closed
berndfuhrmann opened this issue May 8, 2024 · 0 comments · Fixed by #365
Closed

toMap keySelector type is incorrect #364

berndfuhrmann opened this issue May 8, 2024 · 0 comments · Fixed by #365

Comments

@berndfuhrmann
Copy link
Contributor

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.

berndfuhrmann added a commit to berndfuhrmann/IxJS that referenced this issue May 8, 2024
change return type of keySelector from TElement to TKey, since keySelector returns keys, not elements

Closes: ReactiveX#364
trxcllnt pushed a commit that referenced this issue May 8, 2024
change return type of keySelector from TElement to TKey, since keySelector returns keys, not elements

Closes: #364
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant