##// END OF EJS Templates
working on fluent container configuration
working on fluent container configuration

File last commit:

r125:a19ad0acfd39 ioc ts support
r125:a19ad0acfd39 ioc ts support
Show More
Annotations.ts
79 lines | 2.7 KiB | video/mp2t | TypeScriptLexer
/ src / main / ts / di / Annotations.ts
cin
configuration interfaces moved to di/Configuration module...
r118 import { primitive } from "../safe";
cin
working on container configuration dsl
r124 import { TypeRegistration, DependencyRegistration, LazyDependencyRegistration, Registration, StrictTypeRegistration } from "./Configuration";
cin
Initial work on typescript support for the container configuration
r107
export interface InjectOptions {
lazy?: boolean;
}
cin
configuration draft-1
r119 type Compatible<T1, T2> = T2 extends T1 ? any : never;
cin
working on di decorators
r109
cin
Working on IoC container configuration
r111 type ExtractService<K, S> = K extends keyof S ? S[K] : K;
cin
working on di decorators
r109
cin
configuration interfaces moved to di/Configuration module...
r118 type ExtractDependency<D, S> = D extends { $dependency: infer K } ?
D extends { lazy: true } ? () => ExtractService<K, S> : ExtractService<K, S> :
cin
working on container configuration dsl
r124 D extends { $type: new (...args: any[]) => infer I } ? I :
cin
configuration interfaces moved to di/Configuration module...
r118 WalkDependencies<D, S>;
cin
working on di decorators
r109
cin
configuration interfaces moved to di/Configuration module...
r118 type WalkDependencies<D, S> = D extends primitive ? D :
{ [K in keyof D]: ExtractDependency<D[K], S> };
cin
working on di decorators
r109
cin
improved interfaces and more tight type checking
r120 export class Builder<T, S extends object> {
cin
configuration draft-1
r119 declare<P extends any[]>(...args: P) {
cin
Working on IoC container configuration
r111 return <C extends new (...args: ExtractDependency<P, S>) => T>(constructor: C) => {
cin
improved interfaces and more tight type checking
r120
cin
dependency builder proposal
r108 };
}
cin
configuration interfaces moved to di/Configuration module...
r118 inject<P extends any[]>(...args: P) {
return <X extends { [m in M]: (...args: any) => any }, M extends keyof (T | X)>(
target: X,
memberName: M,
descriptor: TypedPropertyDescriptor<Compatible<(...args: ExtractDependency<P, S>) => any, T[M]>>
) => {
cin
dependency builder proposal
r108
};
}
cin
sync
r121 getDescriptor(): TypeRegistration<new () => T, S> {
cin
configuration interfaces moved to di/Configuration module...
r118 throw new Error();
}
cin
configuration draft-1
r119 }
cin
sync
r121 export interface DependencyOptions<T> {
optional?: boolean;
default?: T;
}
export interface LazyDependencyOptions<T> extends DependencyOptions<T> {
lazy: true;
}
cin
improved interfaces and more tight type checking
r120 interface Declaration<S extends object> {
cin
configuration draft-1
r119 define<T>(): Builder<T, S>;
cin
working on container configuration dsl
r124 dependency<K extends keyof S>(name: K, opts: LazyDependencyOptions<S[K]>): LazyDependencyRegistration<S, K>;
dependency<K extends keyof S>(name: K, opts?: DependencyOptions<S[K]>): DependencyRegistration<S, K>;
cin
working on fluent container configuration
r125 $type<T, P extends any[], C extends new (...args: ExtractDependency<P, S>) => T>(target: C, ...params: P): StrictTypeRegistration<C, S>;
cin
configuration draft-1
r119
cin
sync
r123 configure(): Config<S>;
cin
configuration draft-1
r119 }
cin
configuration interfaces moved to di/Configuration module...
r118
cin
improved interfaces and more tight type checking
r120 type ServiceModule<T, S extends object, M extends string = "service"> = {
[m in M]: Builder<T, S>;
};
cin
configuration interfaces moved to di/Configuration module...
r118
cin
Added LazyReferenceDescriptor, removed lazy behaviour from ReferenceDescriptor.
r122 type PromiseOrValue<T> = PromiseLike<T> | T;
cin
sync
r123
cin
improved interfaces and more tight type checking
r120 export interface Config<S extends object, Y extends keyof S = keyof S> {
cin
working on container configuration dsl
r124 register<K extends Y>(name: K, m: { $from: Promise<ServiceModule<S[K], S>> }): Config<S, Exclude<Y, K>>;
cin
sync
r123 register<K extends Y, M extends string>(name: K, m: { $from: Promise<ServiceModule<S[K], S, M>>, service: M }): Config<S, Exclude<Y, K>>;
cin
working on container configuration dsl
r124
register<K extends Y>(name: K, m: Registration<S[K], S>): Config<S, Exclude<Y, K>>;
registerType<K extends Y, P extends any[]>(
name: K, $type: new (...args: ExtractDependency<P, S>) => S[K], ...params: P): Config<S, Exclude<Y, K>>;
cin
dependency builder proposal
r108 }
cin
configuration draft-1
r119
export declare function declare<S extends object>(): Declaration<S>;