Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

168
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda