Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

246
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda