title: Typescript @automapper/core error while creating a map
body: <p>I have a problem with the automapper in the Typescript project. Following the <a href="https://automapperts.netlify.app/docs/getting-started/introduce-to-automapper" rel="nofollow noreferrer">documentation</a> I'm getting an error and I don't what why it occurs and how to solve it, based on the docs it should work as it is. It expects me to init the User object while in the docs there is no initialization and when I do this, then</p>
  <blockquote>
  <p>No overload matches this call.
  Overload 1 of 4, '(sourceObj: obj, destination: new (...args: unknown[]) =&gt; UserDto, source: new (...args: unknown[]) =&gt; obj, options?: MapOptions&lt;obj, UserDto&gt;): UserDto', gave the following error.
  Argument of type 'typeof User' is not assignable to parameter of type 'new (...args: unknown[]) =&gt; obj'.
  Types of construct signatures are incompatible.
  Type 'new (id: Uuid, firstName: UserName, lastName: UserName, email: UserEmail, password?: UserPassword) =&gt; User' is not assignable to type 'new (...args: unknown[]) =&gt; obj'.
  Type 'User' is not assignable to type 'obj'.
  Index signature is missing in type 'User'.
  Overload 2 of 4, '(sourceObj: obj, destination: string, source: string, options?: MapOptions&lt;obj, UserDto&gt;): UserDto', gave the following error.
  Argument of type 'typeof UserDto' is not assignable to parameter of type 'string'.</p>
  </blockquote>
  <p>Classes:</p>
  <pre><code>@Entity('users')
  export class User {
  
    @ObjectIdColumn()
    @AutoMap({ typeFn: () =&gt; Uuid })
    private _id: Uuid;
  
    @Column()
    @AutoMap({ typeFn: () =&gt; UserName })
    private firstName: UserName;
  
    @Column()
    @AutoMap({ typeFn: () =&gt; UserName })
    private lastName: UserName;
  
    @Column()
    @AutoMap({ typeFn: () =&gt; UserEmail })
    private email: UserEmail;
  
    @Column()
    @AutoMap({ typeFn: () =&gt; UserPassword })
    private password: UserPassword;
  }
  
  </code></pre>
  <p>where each of the refs has AutoMap as well:</p>
  <pre><code>export class Uuid {
    @AutoMap()
    private value: string;
  }
  </code></pre>
  <p>the mapper itself:</p>
  <pre><code>import { createMapper } from '@automapper/core';
  import { classes } from '@automapper/classes';
  import { User } from '../User';
  import { UserDto } from '../dto/UserDto';
  
  export const mapper = createMapper({
    name: 'userMApper',
    pluginInitializer: classes,
  });
  
  mapper.createMap(User, UserDto);
  </code></pre>
  <p>and finally where the error occurs is my InMemoryHashMapDatabase:</p>
  <pre><code>findById(id: string): UserDto {
    const user = this.map.get(id);
    return mapper.map(user, UserDto, User);
  }
  </code></pre>
  <p>with initialization and the Object return method .toString()</p>
  <pre><code>findById(id: string): UserDto {
    const user = this.map.get(id);
    return mapper.map(
      user,
      UserDto,
      new User(
          new Uuid(user.id),
          new UserName(user.firstName, UserNameTypes.FIRST),
          new UserName(user.lastName, UserNameTypes.LAST),
          new UserEmail(user.email),
          new UserPassword(user.password),
        ).toString(),
      );
  </code></pre>
  <p>but then I got another error because each of the classes has its own validation</p>
  <pre><code>undefined name field must be provided
    15 |   constructor(name: string, type: UserNameTypes) {
    16 |     if (name == '' || name == null || name == undefined) {
  &gt; 17 |       throw new BadRequestException(`${type} name field must be provided`);
       |             ^
    18 |     }
    19 |
    20 |     if (name.length &lt; UserName.minLength) {
  
    at new UserName (../src/user/domain/UserName.ts:17:13)
    at Object.instantiate (../packages/classes/src/lib/utils/instantiate.util.ts:122:11)
    at Object.instantiate (../packages/classes/src/lib/classes.ts:36:14)
    at Object.initializeMapping (../packages/classes/src/lib/classes.ts:66:64)
    at Object.createMap (../packages/core/src/lib/create-mapper/create-mapper.ts:38:30)
    at Object.&lt;anonymous&gt; (../src/user/domain/mapper/Mapper.ts:11:8)
  </code></pre>
  <p>It sounds like I have to init the User class again in the Mapper.ts file, but there is no input for it.</p>
  <p>I'm using the NestJS framework, but I don't want to integrate it via Modules (so no @InjectMapper() kind of thing), I prefer to use it as it would be a typical ts project.</p>
  <p>EDIT: I've changed to the type of the parameter in the mapper.map() function from</p>
  <pre><code>interface obj {
    [key: string]: string;
  }
  </code></pre>
  <p>to <code>any</code> so <code>mapper.map(user, UserDto, User);</code> seems to be working, but still, there is a problem with initialization where the error <code>undefined name field must be provided</code> occurs.</p>