diff --git a/src/CONST.js b/src/CONST.ts similarity index 96% rename from src/CONST.js rename to src/CONST.ts index 716f5f1c428e..864d078ab04b 100755 --- a/src/CONST.js +++ b/src/CONST.ts @@ -1,4 +1,4 @@ -import lodashGet from 'lodash/get'; +/* eslint-disable @typescript-eslint/naming-convention */ import Config from 'react-native-config'; import * as KeyCommand from 'react-native-key-command'; import * as Url from './libs/Url'; @@ -6,24 +6,24 @@ import SCREENS from './SCREENS'; const CLOUDFRONT_DOMAIN = 'cloudfront.net'; const CLOUDFRONT_URL = `https://d2k5nsl2zxldvw.${CLOUDFRONT_DOMAIN}`; -const ACTIVE_EXPENSIFY_URL = Url.addTrailingForwardSlash(lodashGet(Config, 'NEW_EXPENSIFY_URL', 'https://new.expensify.com')); +const ACTIVE_EXPENSIFY_URL = Url.addTrailingForwardSlash(Config?.NEW_EXPENSIFY_URL ?? 'https://new.expensify.com'); const USE_EXPENSIFY_URL = 'https://use.expensify.com'; const PLATFORM_OS_MACOS = 'Mac OS'; const PLATFORM_IOS = 'iOS'; const ANDROID_PACKAGE_NAME = 'com.expensify.chat'; const CURRENT_YEAR = new Date().getFullYear(); -const PULL_REQUEST_NUMBER = lodashGet(Config, 'PULL_REQUEST_NUMBER', ''); - -const keyModifierControl = lodashGet(KeyCommand, 'constants.keyModifierControl', 'keyModifierControl'); -const keyModifierCommand = lodashGet(KeyCommand, 'constants.keyModifierCommand', 'keyModifierCommand'); -const keyModifierShiftControl = lodashGet(KeyCommand, 'constants.keyModifierShiftControl', 'keyModifierShiftControl'); -const keyModifierShiftCommand = lodashGet(KeyCommand, 'constants.keyModifierShiftCommand', 'keyModifierShiftCommand'); -const keyInputEscape = lodashGet(KeyCommand, 'constants.keyInputEscape', 'keyInputEscape'); -const keyInputEnter = lodashGet(KeyCommand, 'constants.keyInputEnter', 'keyInputEnter'); -const keyInputUpArrow = lodashGet(KeyCommand, 'constants.keyInputUpArrow', 'keyInputUpArrow'); -const keyInputDownArrow = lodashGet(KeyCommand, 'constants.keyInputDownArrow', 'keyInputDownArrow'); -const keyInputLeftArrow = lodashGet(KeyCommand, 'constants.keyInputLeftArrow', 'keyInputLeftArrow'); -const keyInputRightArrow = lodashGet(KeyCommand, 'constants.keyInputRightArrow', 'keyInputRightArrow'); +const PULL_REQUEST_NUMBER = Config?.PULL_REQUEST_NUMBER ?? ''; + +const keyModifierControl = KeyCommand?.constants?.keyModifierControl ?? 'keyModifierControl'; +const keyModifierCommand = KeyCommand?.constants?.keyModifierCommand ?? 'keyModifierCommand'; +const keyModifierShiftControl = KeyCommand?.constants?.keyModifierShiftControl ?? 'keyModifierShiftControl'; +const keyModifierShiftCommand = KeyCommand?.constants?.keyModifierShiftCommand ?? 'keyModifierShiftCommand'; +const keyInputEscape = KeyCommand?.constants?.keyInputEscape ?? 'keyInputEscape'; +const keyInputEnter = KeyCommand?.constants?.keyInputEnter ?? 'keyInputEnter'; +const keyInputUpArrow = KeyCommand?.constants?.keyInputUpArrow ?? 'keyInputUpArrow'; +const keyInputDownArrow = KeyCommand?.constants?.keyInputDownArrow ?? 'keyInputDownArrow'; +const keyInputLeftArrow = KeyCommand?.constants?.keyInputLeftArrow ?? 'keyInputLeftArrow'; +const keyInputRightArrow = KeyCommand?.constants?.keyInputRightArrow ?? 'keyInputRightArrow'; // describes if a shortcut key can cause navigation const KEYBOARD_SHORTCUT_NAVIGATION_TYPE = 'NAVIGATION_SHORTCUT'; @@ -884,22 +884,22 @@ const CONST = { }, ACCOUNT_ID: { - ACCOUNTING: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_ACCOUNTING', 9645353)), - ADMIN: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_ADMIN', -1)), - BILLS: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_BILLS', 1371)), - CHRONOS: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_CHRONOS', 10027416)), - CONCIERGE: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_CONCIERGE', 8392101)), - CONTRIBUTORS: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_CONTRIBUTORS', 9675014)), - FIRST_RESPONDER: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_FIRST_RESPONDER', 9375152)), - HELP: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_HELP', -1)), - INTEGRATION_TESTING_CREDS: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_INTEGRATION_TESTING_CREDS', -1)), - PAYROLL: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_PAYROLL', 9679724)), - QA: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_QA', 3126513)), - QA_TRAVIS: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_QA_TRAVIS', 8595733)), - RECEIPTS: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_RECEIPTS', -1)), - REWARDS: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_REWARDS', 11023767)), // rewards@expensify.com - STUDENT_AMBASSADOR: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_STUDENT_AMBASSADOR', 10476956)), - SVFG: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_SVFG', 2012843)), + ACCOUNTING: Number(Config?.EXPENSIFY_ACCOUNT_ID_ACCOUNTING ?? 9645353), + ADMIN: Number(Config?.EXPENSIFY_ACCOUNT_ID_ADMIN ?? -1), + BILLS: Number(Config?.EXPENSIFY_ACCOUNT_ID_BILLS ?? 1371), + CHRONOS: Number(Config?.EXPENSIFY_ACCOUNT_ID_CHRONOS ?? 10027416), + CONCIERGE: Number(Config?.EXPENSIFY_ACCOUNT_ID_CONCIERGE ?? 8392101), + CONTRIBUTORS: Number(Config?.EXPENSIFY_ACCOUNT_ID_CONTRIBUTORS ?? 9675014), + FIRST_RESPONDER: Number(Config?.EXPENSIFY_ACCOUNT_ID_FIRST_RESPONDER ?? 9375152), + HELP: Number(Config?.EXPENSIFY_ACCOUNT_ID_HELP ?? -1), + INTEGRATION_TESTING_CREDS: Number(Config?.EXPENSIFY_ACCOUNT_ID_INTEGRATION_TESTING_CREDS ?? -1), + PAYROLL: Number(Config?.EXPENSIFY_ACCOUNT_ID_PAYROLL ?? 9679724), + QA: Number(Config?.EXPENSIFY_ACCOUNT_ID_QA ?? 3126513), + QA_TRAVIS: Number(Config?.EXPENSIFY_ACCOUNT_ID_QA_TRAVIS ?? 8595733), + RECEIPTS: Number(Config?.EXPENSIFY_ACCOUNT_ID_RECEIPTS ?? -1), + REWARDS: Number(Config?.EXPENSIFY_ACCOUNT_ID_REWARDS ?? 11023767), // rewards@expensify.com + STUDENT_AMBASSADOR: Number(Config?.EXPENSIFY_ACCOUNT_ID_STUDENT_AMBASSADOR ?? 10476956), + SVFG: Number(Config?.EXPENSIFY_ACCOUNT_ID_SVFG ?? 2012843), }, ENVIRONMENT: { @@ -2599,10 +2599,11 @@ const CONST = { NAVIGATE: 'NAVIGATE', }, }, + DEMO_PAGES: { SAASTR: 'SaaStrDemoSetup', SBE: 'SbeDemoSetup', }, -}; +} as const; export default CONST; diff --git a/src/global.d.ts b/src/types/global.d.ts similarity index 60% rename from src/global.d.ts rename to src/types/global.d.ts index 0dc745d5e0ea..1910b5a994b8 100644 --- a/src/global.d.ts +++ b/src/types/global.d.ts @@ -1,13 +1,13 @@ -import {OnyxKey, OnyxCollectionKey, OnyxValues} from './ONYXKEYS'; - declare module '*.png' { const value: import('react-native').ImageSourcePropType; export default value; } + declare module '*.jpg' { const value: import('react-native').ImageSourcePropType; export default value; } + declare module '*.svg' { import React from 'react'; import {SvgProps} from 'react-native-svg'; @@ -17,12 +17,3 @@ declare module '*.svg' { } declare module 'react-native-device-info/jest/react-native-device-info-mock'; - -declare module 'react-native-onyx' { - // eslint-disable-next-line @typescript-eslint/consistent-type-definitions - interface CustomTypeOptions { - keys: OnyxKey; - collectionKeys: OnyxCollectionKey; - values: OnyxValues; - } -} diff --git a/src/types/modules/react-native-key-command.d.ts b/src/types/modules/react-native-key-command.d.ts new file mode 100644 index 000000000000..f93204891e84 --- /dev/null +++ b/src/types/modules/react-native-key-command.d.ts @@ -0,0 +1,30 @@ +declare module 'react-native-key-command' { + declare const constants = { + keyInputDownArrow: 'keyInputDownArrow', + keyInputEscape: 'keyInputEscape', + keyInputLeftArrow: 'keyInputLeftArrow', + keyInputRightArrow: 'keyInputRightArrow', + keyInputUpArrow: 'keyInputUpArrow', + keyInputEnter: 'keyInputEnter', + keyModifierCapsLock: 'keyModifierCapsLock', + keyModifierCommand: 'keyModifierCommand', + keyModifierControl: 'keyModifierControl', + keyModifierControlCommand: 'keyModifierControlCommand', + keyModifierControlOption: 'keyModifierControlOption', + keyModifierControlOptionCommand: 'keyModifierControlOptionCommand', + keyModifierNumericPad: 'keyModifierNumericPad', + keyModifierOption: 'keyModifierOption', + keyModifierOptionCommand: 'keyModifierOptionCommand', + keyModifierShift: 'keyModifierShift', + keyModifierShiftCommand: 'keyModifierShiftCommand', + keyModifierShiftControl: 'keyModifierShiftControl', + keyModifierAlternate: 'keyModifierAlternate', + } as const; + + type KeyCommand = {input: string; modifierFlags: string}; + + declare function addListener(keyCommand: KeyCommand, callback: (keycommandEvent: KeyCommand, event: Event) => void): () => void; + + // eslint-disable-next-line import/prefer-default-export + export {constants, addListener}; +} diff --git a/src/types/modules/react-native-onyx.d.ts b/src/types/modules/react-native-onyx.d.ts new file mode 100644 index 000000000000..4979f8fd0dbb --- /dev/null +++ b/src/types/modules/react-native-onyx.d.ts @@ -0,0 +1,10 @@ +import {OnyxKey, OnyxCollectionKey, OnyxValues} from '../../ONYXKEYS'; + +declare module 'react-native-onyx' { + // eslint-disable-next-line @typescript-eslint/consistent-type-definitions + interface CustomTypeOptions { + keys: OnyxKey; + collectionKeys: OnyxCollectionKey; + values: OnyxValues; + } +} diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index d52489c36da9..8ed25cb286b0 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -1,5 +1,3 @@ -// TODO: Remove this after CONST.ts is migrated to TS -/* eslint-disable @typescript-eslint/no-duplicate-type-constituents */ import {ValueOf} from 'type-fest'; import CONST from '../../CONST'; diff --git a/src/types/onyx/WalletTransfer.ts b/src/types/onyx/WalletTransfer.ts index c5d92250f91d..3dd28729ba96 100644 --- a/src/types/onyx/WalletTransfer.ts +++ b/src/types/onyx/WalletTransfer.ts @@ -9,8 +9,6 @@ type WalletTransfer = { selectedAccountType?: string; /** Type to filter the payment Method list */ - // TODO: Remove this after CONST.ts is migrated to TS - // eslint-disable-next-line @typescript-eslint/no-duplicate-type-constituents filterPaymentMethodType?: typeof CONST.PAYMENT_METHODS.DEBIT_CARD | typeof CONST.PAYMENT_METHODS.BANK_ACCOUNT; /** Whether the success screen is shown to user. */