Skip to content

Commit

Permalink
fixed append
Browse files Browse the repository at this point in the history
  • Loading branch information
mikalai-snap committed Nov 28, 2024
1 parent 40342fb commit 1479ef2
Showing 1 changed file with 11 additions and 23 deletions.
34 changes: 11 additions & 23 deletions src/Container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,30 +524,18 @@ export class Container<Services = {}> {
* specified by the token.
*/
append = <
Token extends keyof Services,
Tokens extends readonly ValidTokens<Services>[],
// Fn extends {
// (...args: Params): ArrayElement<Services[Token]>;
// token: Token;
// dependencies: Tokens;
// },
Fn extends InjectableFunction<Services, Tokens, Token, ArrayElement<Services[Token]>>,
Params extends MapTokensToTypes<Services, Fn["dependencies"]>,
Deps extends ServicesFromTokenizedParams<Tokens, Params>
Token extends keyof Services,
Tokens extends readonly ValidTokens<Services>[],
Fn extends {
(...args: Params): ArrayElement<Services[Token]>;
token: Token;
dependencies: Tokens;
},
Params extends MapTokensToTypes<Services, Fn["dependencies"]>,
>(
fn: Fn
): Container<AddService<Services, Token, ArrayElement<Services[Token]>[]>> => {
type ee = Fn["dependencies"];
const i = ConcatInjectable<
Token,
Tokens,
Params,
ArrayElement<Services[Token]>[],
Deps
>(fn.token, fn.dependencies, (...args) => fn(...args));
const p = this.providesService(i);
return p;
};
fn: Tokens extends readonly TokenType[] ? Fn : never
): Container<AddService<Services, Token, ArrayElement<Services[Token]>[]>> =>
this.providesService(ConcatInjectable(fn.token, fn.dependencies, (...args: Params) => fn(...args)));

private providesService<
Token extends TokenType,
Expand Down

0 comments on commit 1479ef2

Please sign in to comment.