##// END OF EJS Templates
configuration interfaces moved to di/Configuration module...
configuration interfaces moved to di/Configuration module ActivationType converted to string literals Working on annotations

File last commit:

r118:6738ac4c3072 ioc ts support
r118:6738ac4c3072 ioc ts support
Show More
Annotations.ts
75 lines | 1.9 KiB | video/mp2t | TypeScriptLexer
/ src / main / ts / di / Annotations.ts
cin
Initial work on typescript support for the container configuration
r107 import { Constructor } from "../interfaces";
cin
configuration interfaces moved to di/Configuration module...
r118 import { primitive } from "../safe";
cin
Initial work on typescript support for the container configuration
r107
export interface InjectOptions {
lazy?: boolean;
}
cin
working on IoC configuration
r114 interface Dependency<K extends keyof any> {
$dependency: K;
lazy?: boolean;
}
interface Lazy<K extends keyof any> extends Dependency<K> {
lazy: true;
}
cin
working on di decorators
r109 type Compatible<T1, T2> = T1 extends T2 ? any : never;
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> :
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
configuration interfaces moved to di/Configuration module...
r118 interface Services<S> {
get<K extends keyof S>(name: K): Dependency<K>;
cin
working on IoC configuration
r114
lazy<K extends keyof S>(name: K): Lazy<K>;
cin
configuration interfaces moved to di/Configuration module...
r118 build<T extends object>(): Builder<T, S>;
cin
working on IoC configuration
r114 }
cin
configuration interfaces moved to di/Configuration module...
r118 export declare function services<S extends object>(): Services<S>;
export declare function build<T = never, S = any>(): Builder<T, S>;
cin
working on IoC configuration
r114
cin
dependency builder proposal
r108 export class Builder<T, S> {
cin
Working on IoC container configuration
r111 consume<P extends any[]>(...args: P) {
return <C extends new (...args: ExtractDependency<P, S>) => T>(constructor: C) => {
cin
dependency builder proposal
r108 };
}
cin
configuration interfaces moved to di/Configuration module...
r118 inject<P extends any[]>(...args: P) {
cin
working on di decorators
r109 // K = "bar"
// M = "setValue"
// S[K] = Bar
// T[M] = (value: string) => void
// P[m] = (value: V) => void
cin
configuration interfaces moved to di/Configuration module...
r118 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
Working on IoC container configuration
r112 cast<T2 extends T>(): Builder<T2, S> {
return this as Builder<T2, S>;
}
cin
configuration interfaces moved to di/Configuration module...
r118 get<K extends keyof S>(name: K): Dependency<K> {
throw new Error();
}
lazy<K extends keyof S>(name: K): Lazy<K> {
throw new Error();
}
cin
dependency builder proposal
r108 }