S3854 does not understand class expressions

S3854 does not seem to understand class expressions which we use for mixins:

declare type ConstructorFunction<T> = new (...args: any[]) => T;
declare type AbstractConstructorFunction<T> = abstract new (...args: any[]) => T;

type SomeBaseClass = {};
interface IMyAddedProperties { someNewField: string; }
export function MyAddedPropertiesMixin<T extends SomeBaseClass>(Base: AbstractConstructorFunction<T>) {
    class MyPartialClass extends (Base as AbstractConstructorFunction<SomeBaseClass>) implements IMyAddedProperties {
        someNewField: string;

        constructor(o?: any) {
            super(o); // <-- Unexpected 'super()' because 'super' is not a constructor.sonarlint(typescript:S3854)
            this.someNewField = "test";
        }
    }
    return MyPartialClass as unknown as ConstructorFunction<T & IMyAddedProperties>;
}

Note that both Visual Studio and Visual Studio Code are able to navigate from the super call to AbstractConstructorFunction<T>.

Hello @m-gallesio,

Thank you for your feedback. We’re relying on the implementation of ESLint’s constructor-super rule for this one, and it is running the following check to see if super is a constructor.

As you can see when you paste your code snippet in this AST explorer (select typescript as parser), AbstractConstructorFunction is a ConstructorType node which will not be picked by the aforementioned check.

Could you please elaborate a bit on your usage so we can properly define this use case?

| S3854 does not seem to understand class expressions which we use for mixins:

Best,
Ilia

Acknowledged, I don’t have time right now, I will reply in the following days.