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?