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

248
Views
How to avoid self referring an object in Typescript?

I have this kind of code:

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export const useStore = create<StoreState>((set, get) => {
  const jwtClient = createJWTClient(useStore);
  return {
    dummyState: createDummySlice(set, get, jwtClient),
    userState: createUserSlice(set, get, jwtClient),
  };
});

The function createJWTClient needs the useStore in order to access user tokens and make auth calls.

Also the slices need the jwtClient in order to call some methods with this instance.

The problem is that I refer the useStore object before is actually created but I thought this is just a pointer thing but Typescript complains that:

TS7022: 'useStore' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.

TS7022: 'jwtClient' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
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!