| @@ -1,15 +1,15 | |||
|
|
1 |
|
|
|
|
2 |
|
|
|
|
1 | import { services } from "../di/Annotations"; | |
|
|
2 | import { Bar } from "./Bar"; | |
|
|
3 | 3 |
|
|
|
4 | 4 | // declare required dependencies |
|
|
5 |
|
|
|
|
6 |
|
|
|
|
7 |
|
|
|
|
5 | const config = services<{ | |
|
|
6 | bar: Bar; | |
|
|
7 | }>(); | |
|
|
8 | 8 |
|
|
|
9 | 9 | // export service descriptor |
|
|
10 |
|
|
|
|
10 | export const service = config.build<Box<Bar>>(); | |
|
|
11 | 11 |
|
|
|
12 |
|
|
|
|
12 | @service.consume(config.dependency("bar")) | |
|
|
13 | 13 | export class Box<T> { |
|
|
14 | 14 | private _value: T | undefined; |
|
|
15 | 15 | |
| @@ -25,12 +25,14 function typeRegistration<T, C extends C | |||
|
|
25 | 25 | throw new Error(); |
|
|
26 | 26 | } |
|
|
27 | 27 | |
|
|
28 | declare function register<T>(): { type<C extends Constructor<T>>(target: C, params: Wrap<ConstructorParameters<C>>): TypeDescriptor<T, C>}; | |
|
|
29 | ||
|
|
28 | 30 | type Wrap<T> = T extends primitive ? T : |
|
|
29 | 31 | { [k in keyof T]: Wrap<T[k]> } | TypeDescriptor<T, Constructor<T>>; |
|
|
30 | 32 | |
|
|
31 | 33 | const config: Wrap<Services> = { |
|
|
32 | 34 | foo: typeRegistration(Foo, []), |
|
|
33 | 35 | bar: typeRegistration(Bar, [{ foo: null as any, nested: null as any }]), |
|
|
34 |
box: |
|
|
|
36 | box: register<Box<Foo>>().type(Box, [{ $type: Bar, params: [] }]), | |
|
|
35 | 37 | host: "" |
|
|
36 | 38 | }; |
General Comments 0
You need to be logged in to leave comments.
Login now
