##// END OF EJS Templates
working on IoC configuration
working on IoC configuration

File last commit:

r112:efce7387bfc8 ioc ts support
r114:475b8ce3e850 ioc ts support
Show More
config.ts
68 lines | 1.3 KiB | video/mp2t | TypeScriptLexer
import { Foo } from "./Foo";
import { Bar } from "./Bar";
import { ActivationType } from "../di/interfaces";
import { Builder } from "../di/Annotations";
import { Box } from "./Box";
interface RegistrationOptions {
activation?: ActivationType;
}
interface Dependency<K extends keyof any> {
$dependency: K;
lazy?: boolean;
}
interface Lazy<K extends keyof any> extends Dependency<K> {
lazy: true;
}
type PromiseOrValue<T> = T | PromiseLike<T>;
interface ConfigBuilder<S> {
build<K extends keyof S, T = S[K]>(name: K): Builder<T, S>;
dependency<K extends keyof S>(name: K): Dependency<K>;
lazy<K extends keyof S>(name: K): Lazy<K>;
mapTo<K extends keyof S>(name: K, ctor: () => PromiseOrValue<new (...args: any[]) => S[K]>): ConfigBuilder<S>;
}
interface ContainerServices {
barBox: Box<Bar>;
foo: Foo;
bar: Bar;
password: string;
user: string;
timeout: number;
}
declare function load<M, C extends keyof M>(m: PromiseLike<M>, name: C): () => PromiseLike<M[C]>;
const t = {
barBox: load(import("./Box"), "Box"),
foo: async () => (await import("./Bar")).Bar,
bar: Bar,
password: String,
user: String,
timeout: Number
};
declare const bc: typeof Box;
const x = new bc();
export declare const config: ConfigBuilder<ContainerServices>;