Skip to content
AutoMapper TypeScript
Esc
navigateopen⌘Jpreview
On this page

Transformer plugin

Generate classes-strategy metadata at compile time instead of decorating every model property.

@automapper/classes/transformer-plugin is a public subpath of @automapper/classes. It uses a TypeScript before transformer to add __AUTOMAPPER_METADATA_FACTORY__() methods to model classes.

The default model suffixes are .entity.ts, .model.ts, .vm.ts, and .dto.ts. Override them with modelFileNameSuffix.

export interface AutomapperTransformerPluginOptions {
  modelFileNameSuffix?: string[];
}

Ignore one property

The plugin generates metadata for matching model properties unless they already use @AutoMap(). Add @autoMapIgnore when a property should have no generated metadata:

class UserDto {
  firstName!: string;

  /** @autoMapIgnore */
  internalState!: string;
}

NestJS CLI

{
  "compilerOptions": {
    "plugins": [
      {
        "name": "@automapper/classes/transformer-plugin",
        "options": {
          "modelFileNameSuffix": [".entity.ts", ".dto.ts"]
        }
      }
    ]
  }
}

Nx executors

Nx TypeScript and webpack executors that expose a transformers option can load the same plugin:

{
  "transformers": [
    {
      "name": "@automapper/classes/transformer-plugin",
      "options": { "modelFileNameSuffix": [".dto.ts"] }
    }
  ]
}

Direct compiler integrations

Webpack ts-loader, Rollup TypeScript integrations, and ts-patch can install the exported transformer directly. With ts-patch, use its tspBefore export:

{
  "compilerOptions": {
    "plugins": [
      {
        "transform": "@automapper/classes/transformer-plugin",
        "import": "tspBefore"
      }
    ]
  }
}

Last updated on July 16, 2026

Was this page helpful?