0

Is it possible to inject classes that you can't edit? It seems Inversify is heavily dependent on annotations/decorators but is there another way?

Cristian Vrabie
  • 3,972
  • 5
  • 30
  • 49

1 Answers1

1

From the inversify wiki:

In some cases you may get errors about missing annotations classes provided by a third party modul like:

Error: Missing required @injectable annotation in: SamuraiMaster

You can overcome this problem using the decorate function:

import { decorate, injectable } from "inversify";
import SomeClass from "some-module";

decorate(injectable(), SomeClass);
return SomeClass;

Check out the JS example page on the wiki for more info.

You can also check out the inversify-vanillajs-helpers project.

Remo H. Jansen
  • 23,172
  • 11
  • 70
  • 93