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 12 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
3 changes: 2 additions & 1 deletion src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,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 @@ -446,6 +446,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/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
2 changes: 1 addition & 1 deletion src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,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
14 changes: 7 additions & 7 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import {Beta, Login, PersonalDetails, Policy, PolicyTags, Report, ReportAction, 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 @@ -184,9 +184,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 @@ -311,7 +312,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 @@ -4383,4 +4383,4 @@ export {
canEditWriteCapability,
};

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 @@ -16,7 +16,7 @@ function retrieveMaxCanvasArea() {
useWorker: false,
})
.then(() => ({
onSuccess: (width, height) => {
onSuccess: (width: number, height: number) => {
Onyx.merge(ONYXKEYS.MAX_CANVAS_AREA, width * height);
},
}));
Expand All @@ -27,7 +27,7 @@ function retrieveMaxCanvasArea() {
*/
function retrieveMaxCanvasHeight() {
canvasSize.maxHeight({
onSuccess: (width, height) => {
onSuccess: (width: number, height: number) => {
Onyx.merge(ONYXKEYS.MAX_CANVAS_HEIGHT, height);
},
});
Expand All @@ -38,7 +38,7 @@ function retrieveMaxCanvasHeight() {
*/
function retrieveMaxCanvasWidth() {
canvasSize.maxWidth({
onSuccess: (width) => {
onSuccess: (width: number) => {
Onyx.merge(ONYXKEYS.MAX_CANVAS_WIDTH, width);
},
});
Expand Down
176 changes: 0 additions & 176 deletions src/libs/actions/Card.js

This file was deleted.

Loading
Loading