Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No QA][TS migration] Migrate 'CONST.js' constant to TypeScript #25764

Merged
merged 8 commits into from
Aug 28, 2023
68 changes: 35 additions & 33 deletions src/CONST.js → src/CONST.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
import lodashGet from 'lodash/get';
/* eslint-disable @typescript-eslint/naming-convention */
import Config from 'react-native-config';
blazejkustra marked this conversation as resolved.
Show resolved Hide resolved
// @ts-expect-error Migrate react-native-key-command to Typescript
import * as KeyCommand from 'react-native-key-command';
blazejkustra marked this conversation as resolved.
Show resolved Hide resolved
import * as Url from './libs/Url';
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 as string) ?? 'keyModifierControl';
const keyModifierCommand = (KeyCommand?.constants?.keyModifierCommand as string) ?? 'keyModifierCommand';
const keyModifierShiftControl = (KeyCommand?.constants?.keyModifierShiftControl as string) ?? 'keyModifierShiftControl';
const keyModifierShiftCommand = (KeyCommand?.constants?.keyModifierShiftCommand as string) ?? 'keyModifierShiftCommand';
const keyInputEscape = (KeyCommand?.constants?.keyInputEscape as string) ?? 'keyInputEscape';
const keyInputEnter = (KeyCommand?.constants?.keyInputEnter as string) ?? 'keyInputEnter';
const keyInputUpArrow = (KeyCommand?.constants?.keyInputUpArrow as string) ?? 'keyInputUpArrow';
const keyInputDownArrow = (KeyCommand?.constants?.keyInputDownArrow as string) ?? 'keyInputDownArrow';
const keyInputLeftArrow = (KeyCommand?.constants?.keyInputLeftArrow as string) ?? 'keyInputLeftArrow';
const keyInputRightArrow = (KeyCommand?.constants?.keyInputRightArrow as string) ?? 'keyInputRightArrow';

// describes if a shortcut key can cause navigation
const KEYBOARD_SHORTCUT_NAVIGATION_TYPE = 'NAVIGATION_SHORTCUT';
Expand Down Expand Up @@ -880,24 +881,24 @@ 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
SAASTR: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_SAASTR', 15252830)),
SBE: Number(lodashGet(Config, 'EXPENSIFY_ACCOUNT_ID_SBE', 15305309)),
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
SAASTR: Number(Config?.EXPENSIFY_ACCOUNT_ID_SAASTR ?? 15252830),
SBE: Number(Config?.EXPENSIFY_ACCOUNT_ID_SBE ?? 15305309),
STUDENT_AMBASSADOR: Number(Config?.EXPENSIFY_ACCOUNT_ID_STUDENT_AMBASSADOR ?? 10476956),
SVFG: Number(Config?.EXPENSIFY_ACCOUNT_ID_SVFG ?? 2012843),
},

ENVIRONMENT: {
Expand Down Expand Up @@ -2599,10 +2600,11 @@ const CONST = {
NAVIGATE: 'NAVIGATE',
},
},

DEMO_PAGES: {
SAASTR: 'SaaStrDemoSetup',
SBE: 'SbeDemoSetup',
},
};
} as const;

export default CONST;
2 changes: 0 additions & 2 deletions src/types/onyx/OriginalMessage.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 0 additions & 2 deletions src/types/onyx/WalletTransfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
Loading