chore: use Object.create for better semantics

This commit is contained in:
Lewis Crichton 2024-06-09 21:57:54 +01:00
parent ec5f9f78d3
commit 38624a8661
No known key found for this signature in database

View file

@ -136,11 +136,17 @@ export function $t(key: string, variables?: Record<string, any>): string {
// description: $t("clientTheme.description") // description: $t("clientTheme.description")
// } // }
// and any future accesses of the description prop will result in an up to date translation // and any future accesses of the description prop will result in an up to date translation
return { const descriptor = {
__proto__: String.prototype, configurable: true,
valueOf: getter, enumerable: false,
toString: getter writable: false,
} as unknown as string; value: getter
};
return Object.create(String.prototype, {
toString: descriptor,
valueOf: descriptor
});
} }
interface TranslateProps { interface TranslateProps {