Angular Modernizer
    Preparing search index...

    Transform rule that resolves constructor-injection DIP violations by introducing interfaces and InjectionTokens.

    Problem: @Injectable classes injecting other @Injectable classes by concrete type violate the Dependency Inversion Principle. The consuming class is coupled to the implementation, making it hard to substitute or test in isolation.

    Solution: For each violating constructor parameter:

    1. Extract a public interface (I${ClassName}) from the injected service
    2. Generate an InjectionToken<IClassName> in the injected file
    3. Replace the parameter type with the interface name
    4. Add @Inject(TOKEN) to the parameter
    5. Add all necessary imports to both files

    Before:

    @Injectable()
    export class UserService {
    constructor(private orderService: OrderService) {}
    }

    After (consuming file):

    import { Inject } from '@angular/core';
    import { IOrderService, ORDER_SERVICE_TOKEN } from './order.service';

    @Injectable()
    export class UserService {
    constructor(@Inject(ORDER_SERVICE_TOKEN) private orderService: IOrderService) {}
    }

    After (injected service file):

    import { InjectionToken } from '@angular/core';

    export interface IOrderService {
    getOrder(id: string): Order;
    }
    export const ORDER_SERVICE_TOKEN = new InjectionToken<IOrderService>('order-service');

    Configuration:

    {
    "@angular-modernizer/plugin-solid": {
    "transformationType": "service-dip-violation-transform"
    }
    }

    Idempotency: Parameters that already have an @Inject decorator are skipped. Interfaces that already exist in the injected file are not re-created.

    ServiceDipViolationTransformOrchestrator for detailed transformation logic

    Implements

    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    category: "refactoring" = 'refactoring'

    Rule category for grouping.

    description: "Replaces concrete constructor injection with interface-based injection using InjectionToken" = 'Replaces concrete constructor injection with interface-based injection using InjectionToken'

    Rule description explaining what it does.

    id: "solid:service-dip-violation-transform" = 'solid:service-dip-violation-transform'

    Unique rule identifier (scoped to plugin).

    name: "Service DIP Violation → Interface + InjectionToken" = 'Service DIP Violation → Interface + InjectionToken'

    Human-readable rule name.

    tags: string[] = ...

    Tags for filtering and search.

    Methods