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

166
Vistas
typescript error on tsyringe delay function

I'm trying to inject some dependency with tsyringe delay function but the typescript are warning me with the follow error:

Type 'string' is not assignable to type 'constructor<any>'.ts(2322)
lazy-helpers.d.ts(9, 54): The expected type comes from the return type of this signature.

I need this delay because TypeORM take some time to establish a connection with the database, and if my injection refers to an Database provider, it throw an Exception case the TypeORM don't establish the connection yet.

The code below works, but i thought that is something wrong as typescript is given me the error message, there is a way to resolve that?

Code sample

import { delay, inject, injectable } from "tsyringe";
import { IRandomProvider } from "@shared/container/providers/IRandomProvider";

@injectable()
class RandomClass {
    constructor(
        @inject(delay(() => "RandomProvider"))
        private randomProvider: IRandomProvider
    ) {}

Tsyringe delay helper function doc: https://github.com/microsoft/tsyringe#the-delay-helper-function

tsyringe version: 4.6.0

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