export const DEPENDENCY_KEYS_METADATA_KEY = 'extollo:di:dependencies:ctor'; export const DEPENDENCY_KEYS_PROPERTY_METADATA_KEY = 'extollo:di:dependencies:properties'; export const DEPENDENCY_KEYS_SERVICE_TYPE_KEY = 'extollo:di:service_type'; /** * Interface that designates a particular value as able to be constructed. */ export interface Instantiable { new(...args: any[]): T } /** * Returns true if the given value is instantiable. * @param what */ export function isInstantiable(what: any): what is Instantiable { return (typeof what === 'object' || typeof what === 'function') && 'constructor' in what && typeof what.constructor === 'function' } /** * Type that identifies a value as a static class, even if it is not instantiable. */ export type StaticClass = Function & {prototype: T} & T2 /** * Returns true if the parameter is a static class. * @param something */ export function isStaticClass(something: any): something is StaticClass { return typeof something === 'function' && typeof something.prototype !== 'undefined' } /** * Type used to represent a value that can identify a factory in the container. */ export type DependencyKey = Instantiable | StaticClass | string /** * Interface used to store dependency requirements by their place in the injectable * target's parameters. */ export interface DependencyRequirement { paramIndex: number, key: DependencyKey, overridden: boolean, } /** * Interface used to store dependency requirements by the class property they should * be injected into. */ export interface PropertyDependency { key: DependencyKey, property: string | symbol, } /** * Interface used to keep track of singleton factory values, by their dependency key. */ export interface InstanceRef { key: DependencyKey, value: any, } /** * Interface used to keep track of the injection type of a class. */ export interface InjectionType { type: 'named' | 'singleton', name?: string, }