##// END OF EJS Templates
Added test: Optional dependency with child container...
Added test: Optional dependency with child container Improved container logging

File last commit:

r144:f97a113c3209 v1.4.0-rc4 default
r158:7e27596a76a8 default
Show More
interfaces.ts
56 lines | 2.3 KiB | video/mp2t | TypeScriptLexer
/ src / main / ts / di / fluent / interfaces.ts
cin
working on fluent container configuration
r125 import { primitive } from "../../safe";
cin
Fixed container interfaces, separated ServiceContainer
r144 import { TypeOfService, ContainerKeys, ActivationType, ILifetime, ServiceContainer } from "../interfaces";
cin
Completely removed IoC annotations...
r135 import { ICancellation } 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
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
Completely removed IoC annotations...
r135 export interface DescriptorBuilder<S extends object, T> {
factory(f: (resolve: Resolver<S>) => T): void;
build<T2>(): DescriptorBuilder<S, T2>;
cin
working on fluent configuration
r128
cin
Completely removed IoC annotations...
r135 override<K extends keyof S>(name: K, builder: RegistrationBuilder<S, S[K]>): this;
override<K extends keyof S>(services: { [name in K]: RegistrationBuilder<S, S[K]> }): this;
lifetime(lifetime: "singleton", typeId: any): this;
lifetime(lifetime: ILifetime | Exclude<ActivationType, "singleton">): this;
cleanup(cb: (item: T) => void): this;
cin
working on fluent configuration
r128
cin
working on fluent configuration
r133 value(v: T): void;
cin
working on fluent container configuration
r125 }
cin
added provided and configure methods to the fluent container configuration, added applyConfig method to the container
r142 export interface ContainerConfiguration<S extends object> {
cin
Fixed container interfaces, separated ServiceContainer
r144 apply<S2 extends object>(target: ServiceContainer<S2>, ct?: ICancellation): Promise<ServiceContainer<S2 & S>>;
cin
added provided and configure methods to the fluent container configuration, added applyConfig method to the container
r142 }
cin
Completely removed IoC annotations...
r135 export type RegistrationBuilder<S extends object, T> = (d: DescriptorBuilder<S, T>, ct?: ICancellation) => void | Promise<void>;
export type FluentRegistrations<K extends keyof S, S extends object> = { [k in K]: RegistrationBuilder<S, S[k]> };