mscharley/dot

`@injectable()` should only be necessary for binding types that instantiate the class

Closed this issue · 0 comments

Describe the bug.

Bindings that instantiate the class themselves like .to() and .toSelf() need the metadata from the @injectable() decorator in order to manage the instantiation process, however if you are using a binding type which allows the user to provide the value to inject such as .toConstantValue() or .toDynamicValue() the need for this doesn't exist and no No @injectable() decorator for class should be thrown.

Steps to reproduce

class Foo {}

const c = createContainer();
c.bind(Foo).toConstantValue(new Foo());

c.get(Foo); // The planner shouldn't throw an exception here.

Expected behaviour

No response

IOC-Deco

1.2.10

TypeScript

5.2.2

Decorator type

Typescript Experimental

Node

No response

Add any other context about the problem here.

No response