/** * This is about as close as we can get in Typescript */ export type AbstractConstructor = Function & { prototype: T; }; /** * Standard definition of a constructor. */ export type ClassConstructor = new (...args: any[]) => T; /** * Allow for implicit typing of constants and interfaces. * Inspired by Angular and some colleges at work. */ export declare class InjectionToken { private id; constructor(id: string | symbol); get description(): string; toString(): string; } /** * Universal id that can be bound to a constant, class, or factories. */ export type InjectableId = (string | symbol | AbstractConstructor | ClassConstructor | InjectionToken) & { readonly description?: string; }; /** * Retrieve instances previously bound to the specified InjectableId. */ export interface Injector { /** * Check to see if the existing InjectableId is known (aka has been bound). * Error callbacks may wish to know if a particular InjectableId is available. * Also the Container's bindXXX calls always overwrite any previous bindings, so you may want to use this as a gate. * * @param id The id to check for. * @param ascending If true, this will search up the chain of parent containers (if they exist). Default is false (only checks if the id is bound within this container). */ isIdKnown(id: InjectableId | AbstractConstructor, ascending?: boolean): boolean; /** * Return an instance of previously bound to 'id'. * * @throws Error if the InjectableId was never registered, OR if there are unresolved asynchronous dependencies in the dependency tree for 'id'. */ get(id: InjectableId | AbstractConstructor): T; /** * awaits the asynchronous resolution of all dependencies in the tree for 'id'. */ resolve(id?: InjectableId | AbstractConstructor): Promise; }