Skip to content

Instantly share code, notes, and snippets.

@markvincze
Created January 14, 2018 22:10
Show Gist options
  • Save markvincze/d4cbf940687f676bcf6b4e19c7a7b0f3 to your computer and use it in GitHub Desktop.
Save markvincze/d4cbf940687f676bcf6b4e19c7a7b0f3 to your computer and use it in GitHub Desktop.
travix-di typings
export interface IGeneratedClass<T> {
new (...args: any[]): T;
}
export interface IProvider {
name: string;
useValue?: any;
useDefinedValue?: any;
useFactory?: (...args: any[]) => any;
useClass?: { new(...args: any[]): any; };
deps?: any[];
// NOTE: Providers will have extra properties which are not statically defined here.
// This extra property is needed to make TSC less strict, and enable extra properties.
[others: string]: any;
}
export interface IContainer {
getDeps(container: IProvider): any;
register(container: IProvider): any;
get<T extends IProvider>(name: string): T;
}
export interface IContainerOptions {
containerName: string;
}
export interface IConstructor<T> {
new(): T;
}
export function createClass<T>(extend: T): IGeneratedClass<T>;
export function createContainer(providers: IProvider[], options: IContainerOptions): IConstructor<IContainer>;
export function resolveContainer<T>(Container: IConstructor<T>): T;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment