Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix published provideClass return type inference. #14

Merged
merged 3 commits into from
Nov 28, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ export class Container<Services = {}> {
providesClass = <Token extends TokenType, Service, Tokens extends readonly ValidTokens<Services>[]>(
token: Token,
cls: InjectableClass<Services, Service, Tokens>
) => this.providesService(ClassInjectable(token, cls));
) => this.providesService(ClassInjectable(token, cls)) as Container<AddService<Services, Token, Service>>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer if we have return type explicitly declared on this method. There is a eslint rule for this, I'm thinking to enable it. That will not solve our problem, but that will prevent similar issues to happen in future when TS infers type incorrectly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! 93365db


/**
* Registers a static value as a service in the container. This method is ideal for services that do not
Expand Down