New in Angular 22: @Service
Angular 22 introduces the @Service decorator. This change moves beyond simple syntax updates to redefine how dependency injection intent is expressed in the framework.
The Technical Shift
The @Injectable decorator served as a generic marker for any class participating in dependency injection. It covered services, tokens, and factories without distinction. While functional, this lack of specificity limited compiler optimizations.
@Service provides explicit intent. It declares that a class is a service responsible for business logic or data handling. This distinction allows the Angular compiler to apply specific tree-shaking strategies. Unused services can be removed more aggressively when the compiler recognizes them as @Service rather than generic injectables. The result is a more efficient build process and reduced bundle size.
Benefits for Development
Clarity is the primary benefit. Reading a codebase with @Service decorators removes ambiguity. Developers can instantly identify business logic components without inspecting constructors or documentation.
Performance improvements follow from this clarity. The compiler leverages the specific metadata of @Service to optimize the injection graph. For large applications, this translates to measurable gains in build times and runtime efficiency. Adopting this pattern aligns with current best practices and prepares codebases for future framework enhancements.
Be cautious with classes that are injectable but do not fit the service definition. Retain @Injectable for generic providers or custom tokens where @Service does not apply.
Conclusion
The move to @Service represents a shift toward explicit, intention-driven development. It improves code readability and enables better compiler optimizations. Teams should adopt this pattern to maintain modern standards and ensure long-term application health.