diff --git a/src/languages/en.ts b/src/languages/en.ts index a8b093b2adae..a667c38e9662 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1,7 +1,6 @@ import {CONST as COMMON_CONST} from 'expensify-common/lib/CONST'; import CONST from '../CONST'; import type { - Translation, AddressLineParams, CharacterLimitParams, MaxParticipantsReachedParams, @@ -75,6 +74,15 @@ import type { } from './types'; import * as ReportActionsUtils from '../libs/ReportActionsUtils'; +type StateValue = { + stateISO: string; + stateName: string; +}; + +type States = Record; + +type AllCountries = Record; + /* eslint-disable max-len */ export default { common: { @@ -1662,8 +1670,8 @@ export default { createAccount: 'Create A New Account', logIn: 'Log In', }, - allStates: COMMON_CONST.STATES, - allCountries: CONST.ALL_COUNTRIES, + allStates: COMMON_CONST.STATES as States, + allCountries: CONST.ALL_COUNTRIES as AllCountries, accessibilityHints: { navigateToChatsList: 'Navigate back to chats list', chatWelcomeMessage: 'Chat welcome message', @@ -1757,4 +1765,4 @@ export default { selectSuggestedAddress: 'Please select a suggested address', }, }, -} satisfies Translation; +}; diff --git a/src/languages/es.ts b/src/languages/es.ts index d3525f0375e4..f562ed5fd536 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1,7 +1,6 @@ import CONST from '../CONST'; import * as ReportActionsUtils from '../libs/ReportActionsUtils'; import type { - Translation, AddressLineParams, CharacterLimitParams, MaxParticipantsReachedParams, @@ -72,6 +71,7 @@ import type { SetTheRequestParams, UpdatedTheRequestParams, RemovedTheRequestParams, + EnglishTranslation, } from './types'; /* eslint-disable max-len */ @@ -2249,4 +2249,4 @@ export default { selectSuggestedAddress: 'Por favor, selecciona una dirección sugerida', }, }, -} satisfies Translation; +} satisfies EnglishTranslation; diff --git a/src/languages/translations.ts b/src/languages/translations.ts index 3a04190b2bff..d228394589b2 100644 --- a/src/languages/translations.ts +++ b/src/languages/translations.ts @@ -1,7 +1,7 @@ import en from './en'; import es from './es'; import esES from './es-ES'; -import type {Translation, TranslationFlatObject} from './types'; +import type {TranslationBase, TranslationFlatObject} from './types'; /** * Converts an object to it's flattened version. @@ -12,10 +12,10 @@ import type {Translation, TranslationFlatObject} from './types'; */ // Necessary to export so that it is accessible to the unit tests // eslint-disable-next-line rulesdir/no-inline-named-export -export function flattenObject(obj: Translation): TranslationFlatObject { +export function flattenObject(obj: TranslationBase): TranslationFlatObject { const result: Record = {}; - const recursive = (data: Translation, key: string): void => { + const recursive = (data: TranslationBase, key: string): void => { // If the data is a function or not a object (eg. a string or array), // it's the final value for the key being built and there is no need // for more recursion @@ -27,7 +27,7 @@ export function flattenObject(obj: Translation): TranslationFlatObject { // Recursive call to the keys and connect to the respective data Object.keys(data).forEach((k) => { isEmpty = false; - recursive(data[k] as Translation, key ? `${key}.${k}` : k); + recursive(data[k] as TranslationBase, key ? `${key}.${k}` : k); }); // Check for when the object is empty but a key exists, so that diff --git a/src/languages/types.ts b/src/languages/types.ts index 17c5e1f1a07c..5d1963b404f4 100644 --- a/src/languages/types.ts +++ b/src/languages/types.ts @@ -196,7 +196,7 @@ type UpdatedTheRequestParams = {valueName: string; newValueToDisplay: string; ol // eslint-disable-next-line @typescript-eslint/no-explicit-any type TranslationBaseValue = string | string[] | ((...args: any[]) => string); -type Translation = {[key: string]: TranslationBaseValue | Translation}; +type TranslationBase = {[key: string]: TranslationBaseValue | TranslationBase}; /* Flat Translation Object types */ // Flattens an object and returns concatenations of all the keys of nested objects @@ -222,16 +222,17 @@ type TranslateType = TPath extends keyof TObject : never : never; -type TranslationsType = typeof en; +type EnglishTranslation = typeof en; -type TranslationPaths = FlattenObject; +type TranslationPaths = FlattenObject; type TranslationFlatObject = { - [TKey in TranslationPaths]: TranslateType; + [TKey in TranslationPaths]: TranslateType; }; export type { - Translation, + TranslationBase, + EnglishTranslation, TranslationFlatObject, AddressLineParams, CharacterLimitParams,