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

Typescript createSelector with more than 12 selectors #378

Closed
MrDesjardins opened this issue Oct 8, 2018 · 6 comments
Closed

Typescript createSelector with more than 12 selectors #378

MrDesjardins opened this issue Oct 8, 2018 · 6 comments
Milestone

Comments

@MrDesjardins
Copy link

Hello,

The definition file has the createSelector with a maximum of 12 selectors.

For people who need more than 12, it does not work. Do you have any guidance? Thank you

@AlexeiDarmin
Copy link

I recommend creating a wrapper component with it's own selector that wraps the child component. Then passing up to 12 props down to the child component that would otherwise need more than 12 selectors. This approach gives you up to 24 selectors, personally I have never needed more than that with the code base I'm working with.

@prabirshrestha
Copy link

Ran into this issue too. Typescript 3.0 supports expanding parameters. Might be it is possible? https://blogs.msdn.microsoft.com/typescript/2018/07/30/announcing-typescript-3-0/

// TODO (billg): 5 overloads should *probably* be enough for anybody?
function call<T1, T2, T3, T4, R>(fn: (param1: T1, param2: T2, param3: T3, param4: T4) => R, param1: T1, param2: T2, param3: T3, param4: T4): R
function call<T1, T2, T3, R>(fn: (param1: T1, param2: T2, param3: T3) => R, param1: T1, param2: T2, param3: T3): R
function call<T1, T2, R>(fn: (param1: T1, param2: T2) => R, param1: T1, param2: T2): R
function call<T1, R>(fn: (param1: T1) => R, param1: T1): R;
function call<R>(fn: () => R, param1: T1): R;
function call(fn: (...args: any[]) => any, ...args: any[]) {
    return fn(...args);
}

With spreading parameter list:

function call<TS extends any[], R>(fn: (...args: TS) => R, ...args: TS): R {
    return fn(...args);
}

@AlexeiDarmin
Copy link

@prabirshrestha Exactly that is currently being discussed here:
#340
#366
#351

@kelly-tock
Copy link

is there any workaround in the meantime? have 2 selectors that are maxed out essentially?

@markerikson
Copy link
Contributor

@kelly-tock : I just published https://github.com/reduxjs/reselect/releases/tag/v4.1.0-alpha.0 , which rewrites the typedefs to use variadic args rather than a fixed list of overloads. Does that happen to improve your situation?

Also, do you have a code sample you could paste in of using that many selectors at once?

@markerikson markerikson added this to the 4.1 milestone Oct 17, 2021
@markerikson
Copy link
Contributor

Resolved by #486 .

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

No branches or pull requests

5 participants