Skip to content

fix: Using constructor injection from base class #324

Open
@anton-johansson

Description

@anton-johansson

Description

I have a base class that handles a lot of common logic that my sub classes use. The base class accepts a single dependency, and is only used by the base class. So having a constructor in the sub-class is redundant (and my xo warns about it).

Minimal code-snippet showcasing the problem

abstract class AbstractThing {
    private readonly myDependency: MyDependency;

    constructor(myDependency: MyDependency) {
        this.myDependency = myDependency;
    }
}

@Service()
class RealThing extends AbstractThing {
}

Expected behavior

I expect MyDependency to be injected properly, even without a constructor in the sub class.

Actual behavior

ContainerInstance seems to be injected instead of MyDependency.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: needs triageIssues which needs to be reproduced to be verified report.type: fixIssues describing a broken feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions