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

[TS migration] Migrate '[Remaining Group 2]' lib to TypeScript #32164

Merged
merged 43 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e951bb7
[TS migration] Migrate 'TransactionEdit.js' lib
VickyStash Nov 28, 2023
76c1781
[TS migration] Migrate 'MemoryOnlyKeys' lib
VickyStash Nov 28, 2023
cf2d8e6
[TS migration] Migrate 'CanvasSize.js' lib
VickyStash Nov 28, 2023
819b77a
Add window.d.ts file
VickyStash Nov 28, 2023
2b59ded
[TS migration] Migrate 'Card.js' lib
VickyStash Nov 29, 2023
e4c6b3f
Merge branch 'main' into ts-migration/remaining-group-2
VickyStash Nov 29, 2023
3e15c67
TS update after main merging
VickyStash Nov 29, 2023
ad02a8c
[TS migration] Migrate 'OnyxUpdateManager.ts' lib
VickyStash Nov 29, 2023
21eac29
[TS migration] Migrate 'DemoActions.js' lib
VickyStash Nov 29, 2023
02d646d
[TS migration] Migrate 'TeacherUnite.js' lib
VickyStash Nov 29, 2023
2857187
Code improvements
VickyStash Nov 29, 2023
00cad5e
Fix crash
VickyStash Nov 29, 2023
f205afe
Add @types/canvas-size lib
VickyStash Nov 30, 2023
27c9dde
Update code to use PersonalDetailsList type
VickyStash Nov 30, 2023
2dfbe5d
Update invalid format check
VickyStash Nov 30, 2023
32095a3
Merge branch 'main' into ts-migration/remaining-group-2
VickyStash Nov 30, 2023
6591d04
Merge branch 'main' into ts-migration/remaining-group-2
VickyStash Dec 1, 2023
815f45c
Put onyx update data into separate variables
VickyStash Dec 4, 2023
290bb98
Merge branch 'main' into ts-migration/remaining-group-2
VickyStash Dec 4, 2023
52d1bb8
Merge branch 'main' into ts-migration/remaining-group-2
VickyStash Dec 6, 2023
e51ee0b
Fix TS issue
VickyStash Dec 6, 2023
b3bdb27
Merge branch 'main' into ts-migration/remaining-group-2
VickyStash Dec 7, 2023
8e55cca
Move updates to global.d.ts file
VickyStash Dec 8, 2023
199720b
Merge branch 'main' into ts-migration/remaining-group-2
VickyStash Dec 12, 2023
a96cdbb
Fix ts issues
VickyStash Dec 12, 2023
5641af0
Rename type
VickyStash Dec 12, 2023
84e2fd5
Add comments to window methods
VickyStash Dec 12, 2023
486ae09
Update comment
VickyStash Dec 18, 2023
2aff297
Merge branch 'main' into ts-migration/remaining-group-2
VickyStash Dec 18, 2023
63d934b
Merge branch 'main' into ts-migration/remaining-group-2
VickyStash Dec 20, 2023
d81e9d9
Merge branch 'main' into ts-migration/remaining-group-2
VickyStash Dec 20, 2023
7456afe
Merge branch 'main' into ts-migration/remaining-group-2
VickyStash Dec 21, 2023
51e0a04
Merge branch 'main' into ts-migration/remaining-group-2
VickyStash Dec 27, 2023
776eb1b
Merge branch 'main' into ts-migration/remaining-group-2
VickyStash Jan 2, 2024
633906a
Merge branch 'main' into ts-migration/remaining-group-2
VickyStash Jan 3, 2024
d4ce66f
TS fix after merging main
VickyStash Jan 3, 2024
8a99355
Re-run performance test
VickyStash Jan 3, 2024
8af41a2
Merge branch 'main' into ts-migration/remaining-group-2
VickyStash Jan 3, 2024
25264a1
Merge branch 'main' into ts-migration/remaining-group-2
VickyStash Jan 4, 2024
4de7a5e
Fix lint errors
VickyStash Jan 4, 2024
cdc8118
Merge branch 'main' into ts-migration/remaining-group-2
VickyStash Jan 9, 2024
733b3b1
Updates from main branch
VickyStash Jan 9, 2024
d53f4f2
Merge branch 'main' into ts-migration/remaining-group-2
VickyStash Jan 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions package-lock.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we push these in this PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because @types/canvas-size was added in this PR 😄

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
"@testing-library/jest-native": "5.4.1",
"@testing-library/react-native": "11.5.1",
"@trivago/prettier-plugin-sort-imports": "^4.2.0",
"@types/canvas-size": "^1.2.2",
"@types/concurrently": "^7.0.0",
"@types/jest": "^29.5.2",
"@types/jest-when": "^3.5.2",
Expand Down
3 changes: 2 additions & 1 deletion src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ type OnyxValues = {
[ONYXKEYS.NETWORK]: OnyxTypes.Network;
[ONYXKEYS.CUSTOM_STATUS_DRAFT]: OnyxTypes.CustomStatusDraft;
[ONYXKEYS.INPUT_FOCUSED]: boolean;
[ONYXKEYS.PERSONAL_DETAILS_LIST]: Record<string, OnyxTypes.PersonalDetails>;
[ONYXKEYS.PERSONAL_DETAILS_LIST]: OnyxTypes.PersonalDetailsList;
[ONYXKEYS.PRIVATE_PERSONAL_DETAILS]: OnyxTypes.PrivatePersonalDetails;
[ONYXKEYS.TASK]: OnyxTypes.Task;
[ONYXKEYS.CURRENCY_LIST]: Record<string, OnyxTypes.Currency>;
Expand Down Expand Up @@ -457,6 +457,7 @@ type OnyxValues = {
[ONYXKEYS.COLLECTION.REPORT_USER_IS_LEAVING_ROOM]: boolean;
[ONYXKEYS.COLLECTION.SECURITY_GROUP]: OnyxTypes.SecurityGroup;
[ONYXKEYS.COLLECTION.TRANSACTION]: OnyxTypes.Transaction;
[ONYXKEYS.COLLECTION.TRANSACTION_DRAFT]: OnyxTypes.Transaction;
[ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_TAGS]: OnyxTypes.RecentlyUsedTags;
[ONYXKEYS.COLLECTION.SELECTED_TAB]: string;

Expand Down
4 changes: 2 additions & 2 deletions src/components/ArchivedReportFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import * as ReportUtils from '@libs/ReportUtils';
import useThemeStyles from '@styles/useThemeStyles';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {PersonalDetails, Report, ReportAction} from '@src/types/onyx';
import type {PersonalDetailsList, Report, ReportAction} from '@src/types/onyx';
import Banner from './Banner';

type ArchivedReportFooterOnyxProps = {
/** The reason this report was archived */
reportClosedAction: OnyxEntry<ReportAction>;

/** Personal details of all users */
personalDetails: OnyxEntry<Record<string, PersonalDetails>>;
personalDetails: OnyxEntry<PersonalDetailsList>;
};

type ArchivedReportFooterProps = ArchivedReportFooterOnyxProps & {
Expand Down
4 changes: 2 additions & 2 deletions src/libs/GroupChatUtils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Onyx, {OnyxEntry} from 'react-native-onyx';
import ONYXKEYS from '@src/ONYXKEYS';
import {PersonalDetails, Report} from '@src/types/onyx';
import {PersonalDetailsList, Report} from '@src/types/onyx';
import * as OptionsListUtils from './OptionsListUtils';
import * as ReportUtils from './ReportUtils';

let allPersonalDetails: OnyxEntry<Record<string, PersonalDetails>> = {};
let allPersonalDetails: OnyxEntry<PersonalDetailsList> = {};
Onyx.connect({
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (val) => (allPersonalDetails = val),
Expand Down
4 changes: 2 additions & 2 deletions src/libs/Navigation/Navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function getActiveRouteIndex(stateOrRoute: StateOrRoute, index?: number): number
* @param path - Path that you are looking for.
* @return - Returns distance to path or -1 if the path is not found in root navigator.
*/
function getDistanceFromPathInRootNavigator(path: string): number {
function getDistanceFromPathInRootNavigator(path?: string): number {
let currentState = navigationRef.getRootState();

for (let index = 0; index < 5; index++) {
Expand Down Expand Up @@ -138,7 +138,7 @@ function navigate(route: Route = ROUTES.HOME, type?: string) {
* @param shouldEnforceFallback - Enforces navigation to fallback route
* @param shouldPopToTop - Should we navigate to LHN on back press
*/
function goBack(fallbackRoute: Route, shouldEnforceFallback = false, shouldPopToTop = false) {
function goBack(fallbackRoute?: Route, shouldEnforceFallback = false, shouldPopToTop = false) {
if (!canNavigate('goBack')) {
return;
}
Expand Down
5 changes: 2 additions & 3 deletions src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import Str from 'expensify-common/lib/str';
import {OnyxCollection, OnyxEntry} from 'react-native-onyx';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import {PersonalDetails, Policy, PolicyMembers, PolicyTag, PolicyTags} from '@src/types/onyx';
import {PersonalDetailsList, Policy, PolicyMembers, PolicyTag, PolicyTags} from '@src/types/onyx';
import {EmptyObject, isEmptyObject} from '@src/types/utils/EmptyObject';

type MemberEmailsToAccountIDs = Record<string, number>;
type PersonalDetailsList = Record<string, PersonalDetails>;
type UnitRate = {rate: number};

/**
Expand All @@ -16,7 +15,7 @@ type UnitRate = {rate: number};
function getActivePolicies(policies: OnyxCollection<Policy>): Policy[] | undefined {
return Object.values(policies ?? {}).filter<Policy>(
(policy): policy is Policy =>
policy !== null && policy && (policy.isPolicyExpenseChatEnabled || policy.areChatRoomsEnabled) && policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
policy !== null && policy && (policy.isPolicyExpenseChatEnabled || !!policy.areChatRoomsEnabled) && policy.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
);
}

Expand Down
18 changes: 9 additions & 9 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import CONST from '@src/CONST';
import {ParentNavigationSummaryParams, TranslationPaths} from '@src/languages/types';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import {Beta, Login, PersonalDetails, Policy, PolicyTags, Report, ReportAction, Session, Transaction} from '@src/types/onyx';
import {Beta, Login, PersonalDetails, PersonalDetailsList, Policy, PolicyTags, Report, ReportAction, Session, Transaction} from '@src/types/onyx';
import {Errors, Icon, PendingAction} from '@src/types/onyx/OnyxCommon';
import {ChangeLog, IOUMessage, OriginalMessageActionName} from '@src/types/onyx/OriginalMessage';
import {Message, ReportActions} from '@src/types/onyx/ReportAction';
import {ChangeLog, IOUMessage, OriginalMessageActionName, OriginalMessageCreated} from '@src/types/onyx/OriginalMessage';
import {Message, ReportActionBase, ReportActions} from '@src/types/onyx/ReportAction';
import {Receipt, WaypointCollection} from '@src/types/onyx/Transaction';
import DeepValueOf from '@src/types/utils/DeepValueOf';
import {EmptyObject, isEmptyObject, isNotEmptyObject} from '@src/types/utils/EmptyObject';
Expand Down Expand Up @@ -188,9 +188,10 @@ type OptimisticClosedReportAction = Pick<
>;

type OptimisticCreatedReportAction = Pick<
ReportAction,
'actionName' | 'actorAccountID' | 'automatic' | 'avatar' | 'created' | 'message' | 'person' | 'reportActionID' | 'shouldShow' | 'pendingAction'
>;
ReportActionBase,
'actorAccountID' | 'automatic' | 'avatar' | 'created' | 'message' | 'person' | 'reportActionID' | 'shouldShow' | 'pendingAction'
> &
OriginalMessageCreated;

type OptimisticChatReport = Pick<
Report,
Expand Down Expand Up @@ -317,7 +318,6 @@ type DisplayNameWithTooltips = Array<Pick<PersonalDetails, 'accountID' | 'pronou

type OptionData = {
alternateText?: string | null;
pendingAction?: PendingAction | null;
allReportErrors?: Errors | null;
brickRoadIndicator?: typeof CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR | '' | null;
tooltipText?: string | null;
Expand Down Expand Up @@ -1409,7 +1409,7 @@ function getDisplayNameForParticipant(accountID?: number, shouldUseShortForm = f
}

function getDisplayNamesWithTooltips(
personalDetailsList: PersonalDetails[] | Record<string, PersonalDetails>,
personalDetailsList: PersonalDetails[] | PersonalDetailsList,
isMultipleParticipantReport: boolean,
shouldFallbackToHidden = true,
): DisplayNameWithTooltips {
Expand Down Expand Up @@ -4454,4 +4454,4 @@ export {
shouldAutoFocusOnKeyPress,
};

export type {OptionData};
export type {OptionData, OptimisticCreatedReportAction};
4 changes: 2 additions & 2 deletions src/libs/actions/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,12 @@ function finalReconnectAppAfterActivatingReliableUpdates(): Promise<void | OnyxT
* @param [updateIDFrom] the ID of the Onyx update that we want to start fetching from
* @param [updateIDTo] the ID of the Onyx update that we want to fetch up to
*/
function getMissingOnyxUpdates(updateIDFrom = 0, updateIDTo = 0): Promise<void | OnyxTypes.Response> {
function getMissingOnyxUpdates(updateIDFrom = 0, updateIDTo: number | string = 0): Promise<void | OnyxTypes.Response> {
console.debug(`[OnyxUpdates] Fetching missing updates updateIDFrom: ${updateIDFrom} and updateIDTo: ${updateIDTo}`);

type GetMissingOnyxMessagesParams = {
updateIDFrom: number;
updateIDTo: number;
updateIDTo: number | string;
};

const parameters: GetMissingOnyxMessagesParams = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ function retrieveMaxCanvasArea() {
// More information at: https://github.com/jhildenbiddle/canvas-size/issues/13
canvasSize
.maxArea({
max: Browser.isMobile() ? 8192 : null,
max: Browser.isMobile() ? 8192 : undefined,
usePromise: true,
useWorker: false,
})
.then(() => ({
onSuccess: (width, height) => {
onSuccess: (width: number, height: number) => {
Onyx.merge(ONYXKEYS.MAX_CANVAS_AREA, width * height);
},
}));
Expand Down
176 changes: 0 additions & 176 deletions src/libs/actions/Card.js

This file was deleted.

Loading
Loading