Issues when mapping type from String -> BigNumber #471
Replies: 2 comments 8 replies
-
|
please share the source object ( |
Beta Was this translation helpful? Give feedback.
-
|
This is indeed a bug (and fix has been released with v8.3.4) So the problem was not in the When you call
class Source {
@AutoMap() // josh, the reason you need () => String here is probably because of Vite. Usually, for primitives, you don't need it
foo: string;
}
class Destination {
@AutoMap(() => BigNumber)
foo: BigNumber;
}
createMap(
mapper,
Source,
Destination,
typeConverter(String, BigNumber, str => BigNumber.from(str))
);Here, a
if (typeConverter) {
const originalMapInitializeFn = transformation[
MappingTransformationClassId.memberMapFn
][MapFnClassId.fn] as Selector;
transformation[MappingTransformationClassId.memberMapFn][
MapFnClassId.fn
] = (srcObj: TSource) =>
typeConverter!(originalMapInitializeFn(srcObj)); // you can see here that typeConverter just patches the underline transformation fn
}In other words,
if (typeof mapInitializedValue === 'object') {
const nestedMapping = getMapping(
mapper,
sourceMemberIdentifier as MetadataIdentifier,
destinationMemberIdentifier as MetadataIdentifier
);
// ...
}So the library fails when it tries to find a With 8.3.4, if a property is subject to type converter, it is treated as-is, like a primitive. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have the following two classes:
and
(side note, I didn't think I'd need to provide the type to map to/from in SlippageDetailsResponse, but if I don't do that I get warnings)
I want to map from
SlippageDetailsResponse->SlippageDetails.To do this I've used the following setup:
And to convert:
However, I'm hitting the following error when the conversion code is executed:
I'm wondering if I'm doing something wrong here, or if there's an issue with the library? Thanks!
Beta Was this translation helpful? Give feedback.
All reactions