Angular Modernizer
    Preparing search index...

    Orchestrator for DIP violation transformation: turns concrete constructor injection into interface-based injection.

    For each constructor parameter of an @Injectable class that injects a concrete @Injectable class:

    1. Derives interface name (I${ClassName}) and token name (CLASS_NAME_TOKEN)
    2. Inserts the interface (public method signatures) and the InjectionToken into the injected service file, unless the interface already exists there
    3. Replaces the parameter type with the interface name
    4. Adds @Inject(TOKEN) to the parameter
    5. Ensures all required imports are present in both files
    // before
    constructor(private svc: OrderService) {}
    // after, consuming file
    constructor(@Inject(ORDER_SERVICE_TOKEN) private svc: IOrderService) {}
    // after, injected service file
    export interface IOrderService { methodA(): void; }
    export const ORDER_SERVICE_TOKEN = new InjectionToken<IOrderService>('order-service');

    Works directly on the ts-morph AST and modifies two files (the consuming file and the injected service file). Idempotent: parameters that already have @Inject are skipped. Declaration files are skipped.

    Index

    Constructors

    Methods

    • Converts OrderService → ORDER_SERVICE_TOKEN. Uses word-boundary splitting to handle consecutive capitals (e.g. HTTPClient → HTTP_CLIENT_TOKEN).

      Parameters

      • className: string

      Returns string

    • Computes the relative module specifier from fromPath to toPath. Strips the .ts extension to produce a valid import path.

      Parameters

      • fromPath: string
      • toPath: string

      Returns string