Skip to content

Commit

Permalink
Merge pull request #895 from salesforcecli/sm/nullish-linter-take-2
Browse files Browse the repository at this point in the history
fix: handle null scale
  • Loading branch information
mdonnalley authored Jul 23, 2024
2 parents 9854816 + 2aaab06 commit 2ed52d1
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 2ed52d1

Please sign in to comment.