Angular Modernizer
    Preparing search index...

    Context for transformation operations. Passed to TransformRule.transform() methods.

    Transform contexts allow WRITE operations. Plugins can modify the sourceFile through ts-morph APIs.

    interface TransformContext<TApi = PublicApiType> {
        api: TApi;
        config: Record<string, unknown>;
        filePath: string;
        options?: { autoSave?: boolean; dryRun?: boolean; format?: boolean };
        project: Project;
        sourceFile: SourceFile;
        type: "transform";
    }

    Type Parameters

    • TApi = PublicApiType

    Hierarchy (View Summary)

    Index

    Properties

    api: TApi

    The Public API - the plugin's toolbox. Contains all high-level helpers for analysis and transformation.

    This is THE critical design decision: Plugins don't implement low-level logic. They consume the API.

    config: Record<string, unknown>

    Plugin-specific configuration. Allows users to customize plugin behavior.

    filePath: string

    File path for convenience (derived from sourceFile).

    options?: { autoSave?: boolean; dryRun?: boolean; format?: boolean }

    Transform-specific options.

    Type Declaration

    • OptionalautoSave?: boolean

      Whether to auto-save changes after transformation. Default: true

    • OptionaldryRun?: boolean

      Whether to perform a dry-run (no actual changes). Default: false

    • Optionalformat?: boolean

      Whether to format code after transformation. Default: true

    project: Project

    The ts-morph Project instance. Provides access to the entire codebase for cross-file analysis.

    sourceFile: SourceFile

    The source file being operated on. This is the primary entry point for all plugin operations.

    type: "transform"

    Type discriminator for type safety.