##// END OF EJS Templates
working on fluent configuration, di annotations removed
working on fluent configuration, di annotations removed

File last commit:

r134:511bcc634d65 ioc ts support
r134:511bcc634d65 ioc ts support
Show More
interfaces.ts
48 lines | 2.0 KiB | video/mp2t | TypeScriptLexer
/ src / main / ts / di / fluent / interfaces.ts
cin
working on fluent container configuration
r125 import { primitive } from "../../safe";
cin
working on fluent configuration
r133 import { AnnotationBuilder } from "../Annotations";
import { ILifetime, TypeOfService, ContainerKeys } from "../interfaces";
cin
working on fluent container configuration
r125
cin
working on fluent configuration
r133 export interface DependencyOptions {
cin
fluent configuration interfaces
r127 optional?: boolean;
cin
working on fluent configuration
r133 default?: any;
cin
fluent configuration interfaces
r127 }
cin
working on fluent container configuration
r125
cin
working on fluent configuration
r133 export interface LazyDependencyOptions extends DependencyOptions {
cin
fluent configuration interfaces
r127 lazy: true;
}
cin
working on fluent configuration
r133 export type ExtractService<K, S> = K extends keyof S ? S[K] : never;
cin
fluent configuration interfaces
r127
export type ExtractDependency<D, S> = D extends { $dependency: infer K } ?
cin
working on fluent container configuration
r125 D extends { lazy: true } ? () => ExtractService<K, S> : ExtractService<K, S> :
D extends { $type: new (...args: any[]) => infer I } ? I :
D extends { $factory: (...args: any[]) => infer R } ? R :
WalkDependencies<D, S>;
cin
fluent configuration interfaces
r127 export type WalkDependencies<D, S> = D extends primitive ? D :
cin
working on fluent container configuration
r125 { [K in keyof D]: ExtractDependency<D[K], S> };
cin
fluent configuration interfaces
r127 export type ServiceModule<T, S extends object, M extends keyof any = "service"> = {
cin
working on fluent configuration
r133 [m in M]: AnnotationBuilder<T, S>;
cin
sync
r126 };
cin
working on fluent configuration, di annotations removed
r134 export type InferReferenceType<S extends object, K extends ContainerKeys<S>, O> = O extends { default: infer X } ? (TypeOfService<S, K> | X) :
cin
working on fluent configuration
r133 O extends { optional: true } ? (TypeOfService<S, K> | undefined) :
TypeOfService<S, K>;
export interface Resolver<S extends object> {
cin
working on fluent configuration, di annotations removed
r134 <K extends ContainerKeys<S>, O extends LazyDependencyOptions>(this: void, name: K, opts: O): () => InferReferenceType<S, K, O>;
<K extends ContainerKeys<S>, O extends DependencyOptions>(this: void, name: K, opts?: O): InferReferenceType<S, K, O>;
cin
working on fluent configuration
r128 }
cin
working on fluent configuration
r133 export interface DescriptorBuilder<T, S extends object> {
service(service: AnnotationBuilder<T, S> | ServiceModule<T, S>): void;
cin
working on fluent configuration
r128
cin
working on fluent configuration
r133 factory(f: (resolve: Resolver<S>, activate: <T2>(lifetime: ILifetime, factory: () => T2, cleanup?: (item: T2) => void) => T2) => T): void;
cin
working on fluent configuration
r128
cin
working on fluent configuration
r133 value(v: T): void;
cin
working on fluent container configuration
r125 }
cin
working on fluent configuration
r133 export interface Configuration<S extends object, Y extends keyof S = keyof S> {
register<K extends Y>(name: K, builder: (d: DescriptorBuilder<S[K], S>) => void): Configuration<S, Exclude<Y, K>>;
cin
working on fluent container configuration
r125 }