Search code examples
typescriptinversifyjstypescript-5

Inversify + Typescript 5: TS1239: Unable to resolve signature of parameter decorator when called as an expression


One of my projects uses Inversify for dependency injection like this:

@injectable()
export class MyClass {

constructor(
    @inject(OtherClass) private otherClass: OtherClass,
    ...
) {
}

This always worked fine and should be OK according to the docs, but when trying to upgrade from TS4 to TS5 it results in the following error (which refers to the line with constructor(...)):

error TS1239: Unable to resolve signature of parameter decorator when called as an expression.

Is there anything that can be done about this or is Inversify no longer usable with TS5? If it's no longer compatible, would there be a drop-in replacement for Inversify?


Solution

  • Maybe it's related with your inversify version.. [email protected] seems to work fine

    But as you can see there is changes in TS5 regarding this matter, More Accurate Type-Checking for Parameter Decorators in Constructors Under --experimentalDecorators

    keep it strong