Skip to content

Commit

Permalink
fix: handle null scale
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Jul 23, 2024
1 parent 9854816 commit 2aaab06
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/shared/templates/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ export const createFieldXML = (data: CustomFieldWithFullNameTypeAndLabel, defaul
if (canConvert(data.type)) {
returnValue += getValueSet(data);
returnValue += getPrecisionTag(data);
returnValue += getScaleTag(data);
if (data.scale != null) {
returnValue += getScaleTag(data.scale);
}
}

returnValue += '</CustomField>\n';
Expand Down Expand Up @@ -237,7 +239,7 @@ const getRequiredTag = (data: CustomField): string =>
const getPrecisionTag = (data: CustomField): string =>
data.precision ? `\t<precision>${data.precision}</precision>\n` : '';

const getScaleTag = (data: CustomField): string =>
const getScaleTag = (scale: NonNullable<CustomField['scale']>): string =>
// CustomField thinks this is a number. The UT had it as a string.
// This will work for either(filtering out null / undefined because only ==)
typeof data.scale !== null ? `\t<scale>${data.scale}</scale>\n` : '';
typeof scale !== null ? `\t<scale>${scale}</scale>\n` : '';

0 comments on commit 2aaab06

Please sign in to comment.