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