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

allP types are wrong #2790

Open
mendrik opened this issue Oct 10, 2023 · 2 comments
Open

allP types are wrong #2790

mendrik opened this issue Oct 10, 2023 · 2 comments

Comments

@mendrik
Copy link

mendrik commented Oct 10, 2023

Describe the bug

export function allP<T>(iterable: Iterable<T>): Promise<T[]>;

should most likely be:

export function allP<T>(iterable: Iterable<Promise<T>>): Promise<T[]>;

@char0n
Copy link
Owner

char0n commented Oct 17, 2023

Hi @mendrik,

I wouldn't say so. Here are the tests for allP:

RA.allP([1, 2]); // $ExpectType Promise<number[]>
RA.allP([Promise.resolve(1), Promise.resolve(2)]); // $ExpectType Promise<number[]>
RA.allP(['a', 'b']); // $ExpectType Promise<string[]>
RA.allP([1, 'a']); // $ExpectType Promise<(string | number)[]>
RA.allP([]); // $ExpectType Promise<never[]>
RA.allP(customIterable); // $ExpectType Promise<number[]>
RA.allP('abc'); // $ExpectType Promise<string[]>

// @ts-expect-error
RA.allP({});
// @ts-expect-error
RA.allP(1);

@mendrik mendrik closed this as completed Nov 9, 2023
@mendrik mendrik reopened this Nov 9, 2023
@mendrik
Copy link
Author

mendrik commented Nov 9, 2023

not really, your 2nd test is not right, it passes but if you check the type manually you get this:
image

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

No branches or pull requests

2 participants