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")
// }
// 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 {