Skip to content

Conversation

@yenbekbay
Copy link

Note: these typings will only work with TS 2.8+, as they make use of Conditional types to infer the return types of async functions.

kapture 2018-03-28 at 3 10 31

@developit
Copy link
Owner

developit commented Apr 9, 2018

@yenbekbay It might be wise to hold off on merging typings that require 2.8+ at this point. I think a lot of people are still on 2.7, myself included (2.8 is broken on my projects).

I wonder - do you think it'd be worth doing a PR without the conditional types in the interim?

FWIW I've picked up TypeScript now and would be happy to hack on porting this library over to be written in TS if that's interesting to you.

@developit developit self-requested a review April 9, 2018 16:41
@fimars
Copy link
Contributor

fimars commented Apr 28, 2018

Maybe you can first publish a @types version? @yenbekbay

@CTOlet
Copy link

CTOlet commented Aug 16, 2018

@fimars When will you accept whit PR? Very useful

@fimars
Copy link
Contributor

fimars commented Aug 16, 2018

@nemmo I am not maintaining this project. This PR is as @developit said, some of the broken changes may not be merged now. Maybe you can make a new PR. 🤔

@CTOlet
Copy link

CTOlet commented Aug 16, 2018

There is no any broken changes cause it is just typing definitions that allows to use that library in TypeScript projects.

@fimars
Copy link
Contributor

fimars commented Aug 16, 2018

It might be wise to hold off on merging typings that require 2.8+ at this point. I think a lot of people are still on 2.7, myself included (2.8 is broken on my projects).

I wonder - do you think it'd be worth doing a PR without the conditional types in the interim?

@nemmo author said.

*/
parallel<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(
list: [
AsyncFn<T1>,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to avoid having to cap the list here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, yes, but only if we use rest parameters instead of a single list parameter.

With the introduction of rest parameters with tuple types in TypeScript 3.0 and mapped types on tuples in TypeScript 3.1, we can simplify the type definition for the parallel method to this:

series<T extends any[]>(
  ...list: T
): Promise<{[K in keyof T]: AsyncFnReturnType<T[K]>}>;

But then, it's probably not an option to change the function signature.


However, with the introduction of optional elements in tuple types in TypeScript 3.0, we can get rid of overloads and reduce the method's type definition to:

series<
  T extends [any, any?, any?, any?, any?, any?, any?, any?, any?, any?]
>(
  list: T,
): Promise<{[K in keyof T]: AsyncFnReturnType<T[K]>}>;

Then, we can increase the capping to a higher number of elements (by adding extra any? elements to the generic tuple type) without adding a ton of overloads.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@developit @yenbekbay any chance to get a new version with the updated typings? This is really a blocker for those who use Typescript :(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypeScript is version 3.7 now. Maybe we can do something.

cc @developit

@yenbekbay yenbekbay closed this by deleting the head repository Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants