Skip to content

Arrays mapping is not working #56

@CameliaTrif

Description

@CameliaTrif

Hi,

It seems that mapping arrays using the automapper-ts library doesn't work for me.
Let's take this simple example. I have an interface called UserData and a class called User and I'm trying to map UserData to User.
export interface UserData {
username: string;
myList: number[];
}

export class User {
username: string = '';
myList: number[] = [];
}

In appcomponent (I am working with angular 6) I have the following setup:

export class AppComponent {
user: User;

const userData: UserData = {
username: 'johndoe',
myList: [1,2,3]
}

automapper
.createMap('user-data', 'user')
.convertToType(User);

this.user = automapper.map('UserData', 'User', userData);

console.log('UserData', userData);
console.log('User', this.user);
}

The console displays:
image

As you can see, for User I cannot see/access myList elements, they are not populated.
I didn't find any similar issue reported and as I noticed none of the automapper-ts tests do not cover this case.

Do you have any suggestions?

Thank you,
Camelia

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions