nestjsx/automapper

Metadata for XXXX is a primitive or Array.

anrolmar opened this issue · 1 comments

Hi. I have a dto class and a model class that have an array property defined like this:

@AutoMap()
params: any[]

When I try to map them, I have the following error:

"Metadata for params is a primitive or Array. Consider manual map this property"

Is there any solution for that or do I need to map this property manually?

nartc commented

@anrolmar sorry for the late response. This happens because @AutoMap() will try to guess the type of params and save it as metadata. Because it is any[] and there's no model passed in for @AutoMap() to help out, AutoMapper only knows as this params as some Array. Hence, when AutoMapper tries to map this property, it cannot determine what it should really map. You'd need to manual map this property using forMember()