Skip to content

Commit

Permalink
Merge pull request #5 from lorenzofox3/fix__issue_4
Browse files Browse the repository at this point in the history
fix #4
  • Loading branch information
lorenzofox3 authored Jun 20, 2024
2 parents c27907b + 2b4da27 commit 9a140d1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type ModuleAPI<Registry, PublicAPI extends Array<keyof Registry> = []> = {
type ProviderFnArgs<Registry extends ObjectLike> = {
[key in keyof ExternalDeps<Registry>]:
| ExternalDeps<Registry>[key]
| ((arg?: FlatDependencyTree<Registry>) => ExternalDeps<Registry>[key]);
| ((arg: InjectableMap<Registry>) => ExternalDeps<Registry>[key]); // technically there is no constraint on arg, it is quite the opposite: it may bring new constraints but this gets contrived.
};

export type ProviderFn<
Expand Down
16 changes: 16 additions & 0 deletions src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,19 @@ fromClass: {
// not a class
fromClass(() => 42);
}

issue4: {
let injectables = {
a: ({ value }: { value: number }) => value + 10,
intermediate: () => '120',
};
const provideMissingWithIntermediate = createProvider({
injectables: injectables,
api: ['a']
});


provideMissingWithIntermediate({
value: ({ intermediate }: { intermediate: string }) => Number(intermediate)
})
}

0 comments on commit 9a140d1

Please sign in to comment.