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

Mapped types

Derive pick, omit, and intersection classes while retaining AutoMapper class metadata.

Import mapped-type helpers from @automapper/classes/mapped-types.

Pick properties

class UserSummary extends MapperPickType(User, [
  "id",
  "displayName",
] as const) {}

createMap(mapper, User, UserSummary);

Omit properties

MapperOmitType() removes omitted members from both AutoMapper metadata and the derived TypeScript type. The diagnostic below is generated by TypeScript.

class class PublicUserPublicUser extends MapperOmitType<User, "passwordHash" | "internalNotes">(classRef: Constructor<User>, keys: readonly ("passwordHash" | "internalNotes")[]): MappedType<Omit<User, "passwordHash" | "internalNotes">>MapperOmitType(class UserUser, [
  "passwordHash",
  "internalNotes",
] as type const = readonly ["passwordHash", "internalNotes"]const) {}

createMap<User, PublicUser>(mapper: Mapper, source: ModelIdentifier<User>, destination: ModelIdentifier<PublicUser>, ...mappingConfigFns: (MappingConfiguration<User, PublicUser> | undefined)[]): Mapping<User, PublicUser> (+1 overload)createMap(const mapper: Mappermapper, class UserUser, class PublicUserPublicUser);

declare const const publicUser: PublicUserpublicUser: class PublicUserPublicUser;

const publicUser: PublicUserpublicUser.
displayName: string
displayName
;
const publicUser: PublicUserpublicUser.passwordHash;
Property 'passwordHash' does not exist on type 'PublicUser'.

Intersect classes

class AuditedUser extends MapperIntersectionType(User, AuditFields) {}

The helpers inherit property initializers and AutoMapper metadata from their input classes. MapperIntersectionType combines metadata but does not add a “multiple source objects” map operation; the resulting class is still one model identifier.

Last updated on July 16, 2026

Was this page helpful?