InversifyJS icon indicating copy to clipboard operation
InversifyJS copied to clipboard

Is the options inheritance does not work by design?

Open lolik21 opened this issue 5 years ago • 1 comments

As a user of the library I would expect that the child container will inherit the options of the parent container. Option " skipBaseClassChecks" in particular is not inherited from the parent container.

Expected Behavior

I would expect that the options will be inherited when creating a child container

Current Behavior

The options are not inherited when doing the following: const childContainer = ctx.container.createChild(); childContainer.options.skipBaseClassChecks = true;

Where the ctx is interfaces.Context from the factory binding

Possible Solution

Inherit the options when creating a child container

Steps to Reproduce (for bugs)

  1. Create a container with the options skipBaseClassChecks = true
  2. Create child of the given container
  3. Verify that shipBaseCalssChecks is false in child options

lolik21 avatar Oct 14 '20 10:10 lolik21

Hi @Lolik21 options seems to be inherited:

public createChild(containerOptions?: interfaces.ContainerOptions): Container {
    const child = new Container(containerOptions || this.options);
    child.parent = this;
    return child;
}

Could you provide a minimal example in order to reproduce it? I followed your steps an skipBaseClassChecks is equal to true

notaphplover avatar Apr 17 '21 18:04 notaphplover