UNPKG

ioc-check

Version:

Runtime checks for error free dependency injection.

23 lines (22 loc) 860 B
import { DependencyInjectionError } from "./errors/DependencyInjectionError"; /** * Modifies classes that should not be instantiated directly to throw an error when this error * case happens. * * For example, to use this decorator. Prepend a class declaration with the decorator before it. * It needs to be the last decorator in your list. * * ```javascript * @Singleton // Or any other decorator that is not included in this project * @noDirectInstantiation * class AClass{} * * class BClass extends AClass{ * * new BClass(); // ok * new AClass(); // will throw DependencyInjectionError: AClass ... * ``` * @param constructable The class that should not be instantiated directly */ declare function noDirectInstantiation(constructable: any, _context?: ClassDecoratorContext): any; export { DependencyInjectionError, noDirectInstantiation };