Skip to content

Commit

Permalink
Fix issue with new ServiceProvider type
Browse files Browse the repository at this point in the history
  • Loading branch information
TiMESPLiNTER committed Jan 31, 2024
1 parent 0826c30 commit 0e69e78
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/pimple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import Container, {ServiceKey} from "./container";
import ServiceProvider from "./serviceProvider";

/** Declaration types */
type ProviderDeclaration<T> = (container: Pimple<T>) => void|ServiceProvider<T>;
type ServiceProviderFunction<T> = (container: Pimple<T>) => void;
type ProviderDeclaration<T> = ServiceProviderFunction<T>|ServiceProvider<T>;
type LazyServiceDefinition<T, S> = (container: Pimple<T>) => S;
type ProtectedServiceDefinition<T, S> = () => LazyServiceDefinition<T, S>;
type PlainServiceDefinition<S> = S extends Function ? () => S : S; // If a function, it needs to be wrapped/protected
Expand Down Expand Up @@ -161,7 +162,7 @@ export default class Pimple<T> implements Container<T>
public register(provider: ProviderDeclaration<T>): Pimple<T> {
if (this.instanceOfServiceProvider(provider) && provider.register instanceof Function) {
provider.register(this);
} else {
} else if (provider instanceof Function) {
provider(this);
}

Expand Down

0 comments on commit 0e69e78

Please sign in to comment.