Skip to content

Commit

Permalink
better error message
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-indy committed Sep 18, 2024
1 parent a404bdf commit 26adea0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ type ObjectLike = Record<string, unknown>;
* All the dependencies of the declared injectables on a registry
*/
export type FlatDependencyTree<Registry extends ObjectLike> =
UnionToIntersection<Dependencies<Registry[keyof Registry]>>;
UnionToIntersection<
{
[key in keyof Registry]: Dependencies<Registry[key]>;
}[keyof Registry]
>;

/**
* All the Injectables defined by a registry
Expand Down Expand Up @@ -78,12 +82,8 @@ export type ProviderFn<
/**
* Checks if each injectable match the required dependencies of the entire registry
*/
type ValidateRegistry<Registry extends ObjectLike> = {
[K in keyof Registry]: K extends keyof FlatDependencyTree<Registry>
? Injectable<Registry[K]> extends FlatDependencyTree<Registry>[K]
? Registry[K] // -> fulfilled dependency
: never // -> unfulfilled dependency
: Registry[K]; // -> not a dependency
type ValidateRegistry<Registry extends ObjectLike, Deps = FlatDependencyTree<Registry>> = {
[key in keyof Registry]: key extends keyof Deps ? ((deps?: any) => Deps[key]) | Deps[key] : Registry[key];
};

declare function valueFn<T>(value: T): () => T;
Expand Down

0 comments on commit 26adea0

Please sign in to comment.