You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extremely new to the DI tsyringe, how do we handle optional parameters with@inject decorator?
With the below setup, I get the following error:
Cannot inject the dependency siteUtils in UtilsWeb, Reason: TypeInfo not known for "undefined"
My use case is : the siteUrl and enablePrettyLinks can have undefined values. They are being read from a .yml file
-------------container.register("siteUrl",{useValue: siteUrl});// siteUrl can have undefined valuecontainer.register("enablePrettyLinks",{useValue: enablePrettyLinks});// enablePrettyLinks can have undefined value------------------
@injectable()exportclassUtilsWeb{constructor(
@inject("siteUrl")privatesiteUrl?: string,
@inject("enablePrettyLinks")privateenablePrettyLinks?: boolean){}
...
}
The text was updated successfully, but these errors were encountered:
Extremely new to the DI tsyringe, how do we handle optional parameters with
@inject
decorator?With the below setup, I get the following error:
My use case is : the siteUrl and enablePrettyLinks can have undefined values. They are being read from a .yml file
The text was updated successfully, but these errors were encountered: