How to map a "Map" interface with a complex object? #505
Answered
by
fabio-filho
fabio-filho
asked this question in
Q&A
-
|
Hi, export class SampleItem {
type: string;
name: string;
example?: unknown;
constructor(data?: SampleItem) {
Object.assign(this, data);
}
}
class Entity {
@AutoMap(() => SampleItem)
sample: Map<string, SampleItem>;
@AutoMap(() => Object)
details: Record<string, any>;
}The payload for the problem above: {
sample: {
sampleOne: {
name: 'sample name',
type: SampleTypes.STRING,
example: 'sample example',
} as SampleItem,
},
description: 'description'
}Another problem happens when I use a complex object for the {
description: { des: 'description' } as Record<string, any>,
}Some details - using the ttypescript: "dependencies": {
"@automapper/classes": "^8.7.5",
"@automapper/core": "^8.7.5",
"@automapper/mikro": "^8.7.5",
"@automapper/nestjs": "^8.7.5",
"@automapper/pojos": "^8.7.5",
"@automapper/sequelize": "^8.7.5",
}
module.exports = {
[...]
globals: {
'ts-jest': {
compiler: 'ttypescript',
},
},
}; |
Beta Was this translation helpful? Give feedback.
Answered by
fabio-filho
Sep 16, 2022
Replies: 2 comments
-
|
Convert all your fields to |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
There is no problem at all, I was using the wrong parameters before to map the object, so the mistake was mine. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
fabio-filho
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

There is no problem at all, I was using the wrong parameters before to map the object, so the mistake was mine.