udic 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/di.d.ts +5 -4
- package/package.json +1 -1
package/di.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
declare const tag: unique symbol;
|
|
2
|
+
type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends (x: infer I) => void ? I : never;
|
|
2
3
|
export interface Service<
|
|
3
4
|
T extends string | symbol,
|
|
4
5
|
K
|
|
@@ -11,16 +12,16 @@ export interface Compute<
|
|
|
11
12
|
T extends Dependency[],
|
|
12
13
|
R
|
|
13
14
|
> {
|
|
14
|
-
(args:
|
|
15
|
+
(args: InferRecord<T>): R;
|
|
15
16
|
0: R;
|
|
16
|
-
1:
|
|
17
|
+
1: InferRecord<T>;
|
|
17
18
|
readonly [tag]: null;
|
|
18
19
|
}
|
|
19
20
|
export type AnyService = Service<string | symbol, any>;
|
|
20
21
|
export type AnyCompute = Compute<any[], any>;
|
|
21
22
|
export type Dependency = AnyService | AnyCompute;
|
|
22
|
-
export type InferDependencies<T extends Dependency[]> =
|
|
23
|
-
export type
|
|
23
|
+
export type InferDependencies<T extends Dependency[]> = { [K in keyof T] : T[K][0] };
|
|
24
|
+
export type InferRecord<T extends Dependency[]> = UnionToIntersection<T[number][1]>;
|
|
24
25
|
export declare const service: <T extends string | symbol>(t: T) => (<K>() => Service<T, K>);
|
|
25
26
|
export declare const compute: <
|
|
26
27
|
const T extends Dependency[],
|