diff --git a/.changeset/spotty-apricots-tan.md b/.changeset/spotty-apricots-tan.md index bc1b26e2f4..2b88e3a7f5 100644 --- a/.changeset/spotty-apricots-tan.md +++ b/.changeset/spotty-apricots-tan.md @@ -53,3 +53,5 @@ export const fooServiceFactory = createServiceFactory({ This is of course more verbose than the previous solution where the factory could be customized through `fooServiceFactory({ bar: 'baz' })`, but this is a simplified which in practice should be using static configuration instead. This change is being made because the ability to define an options callback encourages bad design of services factories. When possible, a service should be configurable through static configuration, and the existence of options may discourage that. More importantly though, the existing options do not work well with the dependency injection system of services, which is a problem for callbacks an other more advanced options. This lead to a bad pattern where only a few explicit dependencies where made available in callbacks, rather than providing an API that allowed simple re-implementation of the service with full access to dependency injection. + +A separate benefit of this change is that it simplifies the TypeScript types in a way that allows TypeScript to provide a much better error message when a service factory doesn't properly implement the service interface.