Skip to content

Commit 528e09c

Browse files
committed
fix: can't convert trArgs[0] to string error
1 parent 196d93d commit 528e09c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

.changeset/violet-ducks-tell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@sv443-network/userutils": patch
3+
---
4+
5+
Fix `can't convert trArgs[0] to string` error

lib/translation.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,16 @@ const templateLiteralTransform: TransformTuple<string> = [
388388
}
389389
};
390390

391+
let notStringifiable = false;
392+
try {
393+
String(trArgs[0]);
394+
}
395+
catch {
396+
notStringifiable = true;
397+
}
398+
391399
/** Whether the first args parameter is an object that doesn't implement a custom `toString` method */
392-
const isArgsObject = trArgs[0] && typeof trArgs[0] === "object" && trArgs[0] !== null && String(trArgs[0]).startsWith("[object");
400+
const isArgsObject = trArgs[0] && typeof trArgs[0] === "object" && trArgs[0] !== null && (notStringifiable || String(trArgs[0]).startsWith("[object"));
393401

394402
if(isArgsObject && eachKeyInTrString(Object.keys(trArgs[0]!)))
395403
namedMapping();

0 commit comments

Comments
 (0)