The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Read translatable properties without a cast (#24498)
Félix Malfait44662b1ec70a
diff --git a/packages/twenty-server/src/engine/metadata-modules/application-translation-catalog/utils/resolve-translatable-properties.util.ts b/packages/twenty-server/src/engine/metadata-modules/application-translation-catalog/utils/resolve-translatable-properties.util.tsindex 9a6483a33cc..1a5a91ef8b9 100644--- a/packages/twenty-server/src/engine/metadata-modules/application-translation-catalog/utils/resolve-translatable-properties.util.ts+++ b/packages/twenty-server/src/engine/metadata-modules/application-translation-catalog/utils/resolve-translatable-properties.util.ts@@ -5,26 +5,22 @@ import { ALL_TRANSLATABLE_PROPERTIES_BY_METADATA_NAME } from 'src/engine/metadatimport { type EffectiveEntityI18nContext } from 'src/engine/metadata-modules/utils/effective-entity-i18n-context.type';import { resolveEffectiveEntityPropertyByName } from 'src/engine/metadata-modules/utils/resolve-effective-entity-property.util';-// The registry decides which property to read, so this is the one place a-// dynamic property name meets a concrete entity. Callers range from TypeORM-// classes to plain DTOs, some without an overrides column at all, so the read-// is dynamic rather than typed per shape.-const readProperty = (entity: object, property: string): unknown =>- (entity as Record<string, unknown>)[property];-export const resolveTranslatableProperties = ({metadataName,entity,i18nContext,}: {metadataName: TranslatableMetadataName;- entity: object;+ // The registry decides which properties to read, so the entity is indexed by+ // name: callers range from TypeORM classes to plain DTOs, some without an+ // overrides column at all.+ entity: Record<string, unknown>;i18nContext: EffectiveEntityI18nContext;}): Record<string, string> =>Object.fromEntries((ALL_TRANSLATABLE_PROPERTIES_BY_METADATA_NAME[metadataName] ?? []).map((property) => {- const baseValue = readProperty(entity, property);+ const baseValue = entity[property];return isDefined(baseValue)? [@@ -32,7 +28,7 @@ export const resolveTranslatableProperties = ({resolveEffectiveEntityPropertyByName({metadataName,baseValue,- overrides: readProperty(entity, 'overrides'),+ overrides: entity.overrides,property,i18nContext,}),