From 38624a8661624f082e974503005725856e85ecc8 Mon Sep 17 00:00:00 2001 From: Lewis Crichton Date: Sun, 9 Jun 2024 21:57:54 +0100 Subject: [PATCH] chore: use Object.create for better semantics --- src/utils/translation.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/utils/translation.tsx b/src/utils/translation.tsx index e5f51910c..57d900705 100644 --- a/src/utils/translation.tsx +++ b/src/utils/translation.tsx @@ -136,11 +136,17 @@ export function $t(key: string, variables?: Record): string { // description: $t("clientTheme.description") // } // and any future accesses of the description prop will result in an up to date translation - return { - __proto__: String.prototype, - valueOf: getter, - toString: getter - } as unknown as string; + const descriptor = { + configurable: true, + enumerable: false, + writable: false, + value: getter + }; + + return Object.create(String.prototype, { + toString: descriptor, + valueOf: descriptor + }); } interface TranslateProps {