Aurelia v1 - issue with decorators and TypeScript 5

When using TypeScript 5.x (which is now default in Visual Studio Code) Aurelia v1 decorators are throwing a compilation error.

For this piece of code:

export class Step1 {
    constructor(@newInstance(ValidationService) validationService: ValidationService) {
    }
}
Unable to resolve signature of parameter decorator when called as an expression.
  Argument of type 'typeof Step1' is not assignable to parameter of type 'DependencyCtor<ValidationService, ValidationService, [_ignoreHidden?: boolean | undefined]> & { inject?: (boolean | undefined)[] | undefined; }'.
    Type 'typeof Step1' is not assignable to type 'DependencyCtor<ValidationService, ValidationService, [_ignoreHidden?: boolean | undefined]>'.
      Types of construct signatures are incompatible.
        Type 'new (validationService: ValidationService) => Step1' is not assignable to type 'new (_ignoreHidden?: boolean | undefined) => ValidationService'.ts(1239)

Adding a workaround as any works for the simplest case, where ValidationService constructor does not accept any parameters:

@newInstance(ValidationService as any)

However, for the cases where I need to pass constructor parameters to ValidationService like:

@newInstance(ValidationService, true)

there is no workaround, as far as I can tell.

How are TypeScript definitions generated for Aurealia v1 (since it’s built with ES, not TS)? Is it possible to update or regenerate TS definitions, to fix this issue for TypeScript 5?

We have been using Aurelia 1 with TypeScript 5.X with no issues so far.
I think Aurelia 1 needs its decorators to work in the classic (then experimental, now legacy) way, by specifying the following TypeScript compiler options:

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  }
}

@m-gallesio No, unfortunately configuration is not the issue. Experimental decorators have been turned on in this project since years. If I compile it with TypeScript 4.9.5 everything works fine.

I suspect that you don’t have the issue because you don’t use decorators in constructors. I also have no issue putting @autoinject on top of the class.

The error states that issue is that return type of @newInstance is a parent class (Step1) and not actual type I want to instantiate (ValidationService). I suspect that TypeScript 5 is more precise with decorator return types than earlier versions, due to work that also went in ES decorators, so it catches the type error that has been there all the time.

Indeed, we mostly use bindable and autoinject.
This (turning off type checking for the decorator function) might work as a workaround:

@(newInstance as any)(MyService, parameters) myService: MyService