Skip to content

Commit

Permalink
fix(core): handle stringify symbol
Browse files Browse the repository at this point in the history
ISSUE: #501
  • Loading branch information
Chau Tran committed Aug 31, 2022
1 parent 2d142f6 commit 0f7f90d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/lib/mappings/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export function map<
const errorMessage = `
Error at "${destinationMemberPath}" on ${
(destinationIdentifier as Constructor)['prototype']
?.constructor?.name || destinationIdentifier
?.constructor?.name || destinationIdentifier.toString()
} (${JSON.stringify(destination)})
---------------------------------------------------------------------
Original error: ${originalError}`;
Expand Down
20 changes: 14 additions & 6 deletions packages/core/src/lib/utils/assert-unmapped-properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,25 @@ export function assertUnmappedProperties<
[] as string[]
);

const sourceText = getTextFromIdentifier(sourceIdentifier);
const destinationText = getTextFromIdentifier(destinationIdentifier);

if (unmappedKeys.length) {
const parentInfo = `${
(sourceIdentifier as Constructor)['name'] ?? sourceIdentifier
} -> ${
(destinationIdentifier as Constructor)['name'] ??
destinationIdentifier
}`;
const parentInfo = `${sourceText} -> ${destinationText}`;
errorHandler.handle(`
Unmapped properties for ${parentInfo}:
-------------------
${unmappedKeys.join(',\n')}
`);
}
}

function getTextFromIdentifier(identifier: MetadataIdentifier): string {
let text = identifier.toString();

if ((identifier as Constructor).name) {
text = (identifier as Constructor).name;
}

return text;
}

0 comments on commit 0f7f90d

Please sign in to comment.