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

Typing for all forces homogenous values #523

Open
jjoekoullas opened this issue Apr 19, 2021 · 0 comments
Open

Typing for all forces homogenous values #523

jjoekoullas opened this issue Apr 19, 2021 · 0 comments

Comments

@jjoekoullas
Copy link

all assumes a shared type between arguments, causing the type inference to devolve to any for types that don't share a more refined base type.

Promise.all handles this well, if via a bit of a hack:
all<T1, T2>(values: readonly [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>;

I believe typed-redux-saga could do something similar -

export type All<
    T1 extends (...args: any[]) => any,
    T2 extends (...args: any[]) => any
> =
    (toRun: [SagaGenerator<SagaReturnType<T1>>, SagaGenerator<SagaReturnType<T2>>])
    => SagaGenerator<[SagaReturnType<T1>, SagaReturnType<T2>]>

essentially it'd be nice if all just converted from [generator<T>, generator<T1>,...etc] into generator<[T, T1]>

I'd like to submit a PR for this, however I'm having trouble understanding the original signature for all - specifically the second argument for the returned SagaGenerator<EffectReturnType<T>[], AllEffect<T>>. What is that second parameter for? I imagine it will need to change (perhaps in redux-saga) to support this.

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

1 participant