Libraries
    Preparing search index...

    Class Mapper<TFromSchema, TToSchema, TUnmapped, TRegistered>

    A fluent builder for configuring how each target property is populated from a source schema. Uses PropertyDescriptors as pointers to properties (similar to expressions in C# .NET).

    The TUnmapped type parameter tracks which target properties have not yet been mapped or ignored. getMapper() is only callable (without arguments) when TUnmapped is never — i.e. all properties have been accounted for. If any property is missing, TypeScript will produce a compile-time type error (a type-assignability mismatch that includes the unmapped property names in its type parameters).

    Type Parameters

    • TFromSchema extends ObjectSchemaBuilder<any, any, any>

      source ObjectSchemaBuilder

    • TToSchema extends ObjectSchemaBuilder<any, any, any>

      target ObjectSchemaBuilder

    • TUnmapped extends string = SchemaKeys<TToSchema>

      union of target property key names not yet mapped

    • TRegistered = never
    Index

    Constructors

    Properties

    Methods

    Constructors

    • Creates a new instance of the Mapper class.

      Type Parameters

      • TFromSchema extends ObjectSchemaBuilder<any, any, any, undefined, false, {}>

        source ObjectSchemaBuilder

      • TToSchema extends ObjectSchemaBuilder<any, any, any, undefined, false, {}>

        target ObjectSchemaBuilder

      • TUnmapped extends string = SchemaKeys<TToSchema>

        union of target property key names not yet mapped

      • TRegistered = never

      Parameters

      • fromSchema: TFromSchema

        object schema to map from

      • toSchema: TToSchema

        object schema to map to

      • Optionalregistry: MappingRegistry<any>

        optional MappingRegistry to auto-register the mapper

      Returns Mapper<TFromSchema, TToSchema, TUnmapped, TRegistered>

    Properties

    "[SYMBOL_UNMAPPED]": TUnmapped

    Phantom property for structural type-checking of TUnmapped.

    Methods

    • Returns the configured async mapping function.

      Compile-time safety: This method is only callable without arguments when all target properties have been mapped or explicitly ignored. If any property is unmapped, TypeScript will require a string argument describing the unmapped properties, producing a clear compile-time error.

      Runtime safety: Even if TypeScript checks are bypassed (e.g. via as any), a MapperConfigurationError is thrown at runtime listing the unmapped properties.

      Parameters

      Returns SchemaToSchemaMapperResult<TFromSchema, TToSchema>