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] Standardize approach to Onyx pendingFields #34799

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3d3aeaa
Create OfflineFeedback type
VickyStash Jan 19, 2024
3a42ec7
Use OfflineFeedback type instead of pendingAction
VickyStash Jan 19, 2024
4a1c14e
Fix lint errors
VickyStash Jan 19, 2024
284d119
Fix lint error in SidebarUtils
VickyStash Jan 19, 2024
3bce79c
Update PendingFields type and add OnyxItemWithOfflineFeedback type
VickyStash Jan 22, 2024
4aaad12
Use OfflineFeedback where possible
VickyStash Jan 23, 2024
abed5f1
Merge branch 'main' into ts-migration/standardize-pendingFields
VickyStash Jan 23, 2024
25552df
Update PolicyReportField import
VickyStash Jan 23, 2024
60fe816
Merge branch 'main' into ts-migration/standardize-pendingFields
VickyStash Jan 25, 2024
809707a
Update OnyxValueWithOfflineFeedback type and reuse it
VickyStash Jan 25, 2024
8682a4d
Remove extra export
VickyStash Jan 25, 2024
66808bf
Merge branch 'main' into ts-migration/standardize-pendingFields
VickyStash Jan 26, 2024
aa6e0e3
Lint fix after conflicts resolution
VickyStash Jan 26, 2024
c028794
Merge branch 'main' into ts-migration/standardize-pendingFields
VickyStash Jan 29, 2024
648e293
Lint fix
VickyStash Jan 29, 2024
a8e53ff
Merge branch 'main' into ts-migration/standardize-pendingFields
VickyStash Jan 30, 2024
5886dcb
Merge branch 'main' into ts-migration/standardize-pendingFields
VickyStash Jan 31, 2024
97bba27
Merge branch 'main' into ts-migration/standardize-pendingFields
VickyStash Feb 1, 2024
98925a5
Merge branch 'main' into ts-migration/standardize-pendingFields
VickyStash Feb 6, 2024
187ffd9
TS fixes after merging main
VickyStash Feb 6, 2024
d559b2e
Merge branch 'main' into ts-migration/standardize-pendingFields
VickyStash Feb 9, 2024
4578ca8
TS fix
VickyStash Feb 9, 2024
f0bb6ed
Merge branch 'main' into ts-migration/standardize-pendingFields
VickyStash Feb 20, 2024
3b5834f
Minor code improvement
VickyStash Feb 21, 2024
939a88c
Merge branch 'main' into ts-migration/standardize-pendingFields
VickyStash Feb 22, 2024
fc6c412
Merge branch 'main' into ts-migration/standardize-pendingFields
VickyStash Feb 23, 2024
8163d2c
Merge branch 'main' into ts-migration/standardize-pendingFields
VickyStash Feb 26, 2024
7d5e4e8
Fix TS error
VickyStash Feb 26, 2024
f52baac
Merge branch 'main' into ts-migration/standardize-pendingFields
VickyStash Feb 26, 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
8 changes: 5 additions & 3 deletions src/types/onyx/Login.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type * as OnyxCommon from './OnyxCommon';

type Login = OnyxCommon.OfflineFeedback<'defaultLogin' | 'validateLogin' | 'addedLogin' | 'deletedLogin' | 'validateCodeSent'> & {
type Login = {
/** Phone/Email associated with user */
partnerUserID?: string;

Expand All @@ -17,7 +17,9 @@ type Login = OnyxCommon.OfflineFeedback<'defaultLogin' | 'validateLogin' | 'adde
errorFields?: OnyxCommon.ErrorFields;
};

type LoginList = Record<string, Login>;
type LoginWithOfflineFeedback = OnyxCommon.OnyxItemWithOfflineFeedback<Login, keyof Login | 'defaultLogin' | 'validateLogin' | 'addedLogin' | 'deletedLogin'>;
VickyStash marked this conversation as resolved.
Show resolved Hide resolved

export default Login;
type LoginList = Record<string, LoginWithOfflineFeedback>;

export default LoginWithOfflineFeedback;
VickyStash marked this conversation as resolved.
Show resolved Hide resolved
export type {LoginList};
6 changes: 4 additions & 2 deletions src/types/onyx/OnyxCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type CONST from '@src/CONST';

type PendingAction = ValueOf<typeof CONST.RED_BRICK_ROAD_PENDING_ACTION> | null;

type PendingFields<TKey extends string> = {[key in TKey]?: PendingAction};
type PendingFields<TKey extends string> = {[key in Exclude<TKey, 'pendingAction' | 'pendingFields'>]?: PendingAction};

type OfflineFeedback<TKey extends string = string> = {
/** The type of action that's pending */
Expand All @@ -14,6 +14,8 @@ type OfflineFeedback<TKey extends string = string> = {
pendingFields?: PendingFields<TKey>;
};

type OnyxItemWithOfflineFeedback<TOnyx, TKey extends string = string> = TOnyx & OfflineFeedback<TKey>;
VickyStash marked this conversation as resolved.
Show resolved Hide resolved

type ErrorFields<TKey extends string = string> = Record<TKey, Errors | null | undefined>;

type Errors = Record<string, string>;
Expand All @@ -37,4 +39,4 @@ type Icon = {
fallbackIcon?: AvatarSource;
};

export type {Icon, PendingAction, ErrorFields, Errors, AvatarType, OfflineFeedback};
export type {Icon, PendingAction, ErrorFields, Errors, AvatarType, OfflineFeedback, OnyxItemWithOfflineFeedback};
8 changes: 5 additions & 3 deletions src/types/onyx/PersonalDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type Status = {
clearAfter: string; // ISO 8601 format;
};

type PersonalDetails = OnyxCommon.OfflineFeedback<'avatar' | 'originalFileName'> & {
type PersonalDetails = {
/** ID of the current user from their personal details */
accountID: number;

Expand Down Expand Up @@ -81,8 +81,10 @@ type PersonalDetails = OnyxCommon.OfflineFeedback<'avatar' | 'originalFileName'>
status?: Status;
};

type PersonalDetailsList = Record<string, PersonalDetails | null>;
type PersonalDetailsWithOfflineFeedback = OnyxCommon.OnyxItemWithOfflineFeedback<PersonalDetails, keyof PersonalDetails>;
VickyStash marked this conversation as resolved.
Show resolved Hide resolved

export default PersonalDetails;
type PersonalDetailsList = Record<string, PersonalDetailsWithOfflineFeedback | null>;

export default PersonalDetailsWithOfflineFeedback;
VickyStash marked this conversation as resolved.
Show resolved Hide resolved

export type {Timezone, Status, SelectedTimezone, PersonalDetailsList};
6 changes: 4 additions & 2 deletions src/types/onyx/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type CustomUnit = OnyxCommon.OfflineFeedback & {

type AutoReportingOffset = number | ValueOf<typeof CONST.POLICY.AUTO_REPORTING_OFFSET>;

type Policy = OnyxCommon.OfflineFeedback<'generalSettings' | 'avatar' | 'addWorkspaceRoom'> & {
type Policy = {
/** The ID of the policy */
id: string;

Expand Down Expand Up @@ -106,6 +106,8 @@ type Policy = OnyxCommon.OfflineFeedback<'generalSettings' | 'avatar' | 'addWork
primaryLoginsInvited?: Record<string, string>;
};

export default Policy;
type PolicyWithOfflineFeedback = OnyxCommon.OnyxItemWithOfflineFeedback<Policy, keyof Policy | 'generalSettings' | 'addWorkspaceRoom'>;

export default PolicyWithOfflineFeedback;
VickyStash marked this conversation as resolved.
Show resolved Hide resolved

export type {Unit, CustomUnit};
6 changes: 4 additions & 2 deletions src/types/onyx/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type Route = {

type Routes = Record<string, Route>;

type Transaction = OnyxCommon.OfflineFeedback<'comment' | 'created' | 'amount' | 'currency' | 'merchant' | 'waypoints' | 'billable' | 'category' | 'tag'> & {
type Transaction = {
amount: number;
billable: boolean;
category: string;
Expand Down Expand Up @@ -94,5 +94,7 @@ type Transaction = OnyxCommon.OfflineFeedback<'comment' | 'created' | 'amount' |
originalCurrency?: string;
};

export default Transaction;
type TransactionWithOfflineFeedback = OnyxCommon.OnyxItemWithOfflineFeedback<Transaction, keyof Transaction | keyof Comment>;

export default TransactionWithOfflineFeedback;
VickyStash marked this conversation as resolved.
Show resolved Hide resolved
export type {WaypointCollection, Comment, Receipt, Waypoint};
Loading