# HG changeset patch # User cin # Date 2020-07-02 00:32:06 # Node ID e81085d00fcbae18454702c2d0f48ac6a4f1bc53 # Parent 691199f665e0e96facb369a2231aa4172c901b9f sync diff --git a/src/test/ts/mock/config.ts b/src/test/ts/mock/config.ts --- a/src/test/ts/mock/config.ts +++ b/src/test/ts/mock/config.ts @@ -1,64 +1,36 @@ 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 { - $dependency: K; - - lazy?: boolean; -} +import { primitive } from "../safe"; +import { Constructor } from "../interfaces"; -interface Lazy extends Dependency { - lazy: true; -} - -type PromiseOrValue = T | PromiseLike; - -interface ConfigBuilder { - build(name: K): Builder; - - dependency(name: K): Dependency; - - lazy(name: K): Lazy; - - mapTo(name: K, ctor: () => PromiseOrValue S[K]>): ConfigBuilder; - -} - -interface ContainerServices { - barBox: Box; - +interface Services { foo: Foo; bar: Bar; - password: string; + box: Box; + + host: string; - user: string; +} - timeout: number; +interface TypeDescriptor> { + $type: C; + + params: Wrap>; } -declare function load(m: PromiseLike, name: C): () => PromiseLike; +function typeRegistration>(target: C, params: Wrap>): TypeDescriptor { + throw new Error(); +} -const t = { - barBox: load(import("./Box"), "Box"), - - foo: async () => (await import("./Bar")).Bar, - - bar: Bar, +type Wrap = T extends primitive ? T : + { [k in keyof T]: Wrap } | TypeDescriptor>; - password: String, - - user: String, - - timeout: Number +const config: Wrap = { + foo: typeRegistration(Foo, []), + bar: typeRegistration(Bar, [{ foo: null as any, nested: null as any }]), + box: typeRegistration(Box, [{ $type: Bar, params: [] }]), + host: "" }; - -export declare const config: ConfigBuilder;