Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

183
Views
createSelector with typescript

I have a very simple selector from reselect library:

const getUsers = (state: State): User[] => state.users;

type ExtendedUser = User & { role: string };

const userRoleSelector = createSelector(
  getUsers,
  (users: User[]): ExtendedUser[] => users.map((user) => ({ ...user, role: "basic" })),
);

I wanted to use it with typescript generics built in for createSelector:

export function createSelector<S, R1, T>(
  selector: Selector<S, R1>,
  combiner: (res: R1) => T
): OutputSelector<S, T, (res: R1) => T>

export function createSelector<S, P, R1, T>(
   selector: ParametricSelector<S, P, R1>,
  combiner: (res: R1) => T
): OutputParametricSelector<S, P, T, (res: R1) => T>

So I used it as:

const userRoleSelector = createSelector<State>(...);
                                        ^^^^ error (expected minimum 3 type arguments)

Question

What should I place in <> ? Thanks!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!