util: Stringify possibly undefined values.

This avoids "@typescript-eslint/restrict-template-expressions" when we
convert util.js to util.ts.

Note that prettier would otherwise split the first template literal
expression in half if we don't start a newline.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
Zixuan James Li 2022-11-20 22:56:36 -08:00 committed by Tim Abbott
parent a63d3507ac
commit 55793cb4d5
2 changed files with 5 additions and 2 deletions

View File

@ -413,7 +413,7 @@ test("catch_buggy_draft_error", () => {
// An error is logged but the draft isn't fixed in this codepath.
blueslip.expect(
"error",
"Cannot compare strings; at least one value is undefined: undefined, old_topic",
"Cannot compare strings; at least one value is undefined: (undefined), old_topic",
);
drafts.rename_stream_recipient(
stream_B.stream_id,

View File

@ -41,7 +41,10 @@ export function lower_bound(array, value, less) {
export const lower_same = function lower_same(a, b) {
if (a === undefined || b === undefined) {
blueslip.error(`Cannot compare strings; at least one value is undefined: ${a}, ${b}`);
blueslip.error(
`Cannot compare strings; at least one value is undefined: \
${a ?? "(undefined)"}, ${b ?? "(undefined)"}`,
);
return false;
}
return a.toLowerCase() === b.toLowerCase();