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

156
Views
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
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!