[No QA][TS Migration] Add comments for remaining properties in Onyx types#41956
Conversation
src/types/onyx/Policy.ts
Outdated
| * Data imported from QuickBooks Online. | ||
| */ | ||
| type QBOConnectionData = { | ||
| /** TODO: I think this value can be changed to `ValueOf<CONST.COUNTRY>` */ |
There was a problem hiding this comment.
Putting comment here for me to get back to this later.
There was a problem hiding this comment.
Let's test it or leave as it is
…-remaining-onyx-types # Conflicts: # src/types/onyx/Policy.ts # src/types/onyx/Report.ts # src/types/onyx/ReportAction.ts
…-remaining-onyx-types # Conflicts: # src/types/onyx/IOU.ts
…-remaining-onyx-types
blazejkustra
left a comment
There was a problem hiding this comment.
Overall a massive improvement, let's aim to get rid of all TODOs in the code and have some internal eyes on the PR 🙌
…-remaining-onyx-types
blazejkustra
left a comment
There was a problem hiding this comment.
Almost LGTM, let's aim to remove all TODOs by either removing the properties or adding minimal context on them.
src/types/onyx/IOU.ts
Outdated
| /** Whether the IOU participant is an invoice sender */ | ||
| isSender?: boolean; | ||
|
|
||
| /** TODO: I think this type could be changes to `IOUType` */ |
src/types/onyx/Report.ts
Outdated
| /** TODO: Doesn't exist in the app */ | ||
| managerEmail?: string; | ||
|
|
||
| /** TODO: Doesn't exist in the app */ | ||
| parentReportActionIDs?: number[]; |
There was a problem hiding this comment.
I think you can remove these fields
src/types/onyx/Report.ts
Outdated
| /** Text to be displayed in options list, which matches reportName by default */ | ||
| text?: string; | ||
|
|
||
| /** TODO: Doesn't exist in the app */ |
There was a problem hiding this comment.
Not used in the app, let's remove
src/types/onyx/ReportAction.ts
Outdated
| /** TODO: Only used in tests */ | ||
| whisperedTo?: number[]; | ||
|
|
||
| /** TODO: Only used in tests */ | ||
| reactions?: Reaction[]; |
There was a problem hiding this comment.
It's used in src/libs/ReportActionsUtils.ts, let's add the context for these props
src/types/onyx/ReportAction.ts
Outdated
| /** TODO: not enough context, seems to be used in tests only */ | ||
| automatic?: boolean; | ||
|
|
||
| /** TODO: Not enough context, seems to be used in tests only */ | ||
| shouldShow?: boolean; |
There was a problem hiding this comment.
I'm pretty sure we could remove both, but it would take a lot of refactor in ReportUtils.ts and tests. How about marking these as @depracated with explanation?
src/types/onyx/ReportAction.ts
Outdated
| /** The user's ID */ | ||
| accountID?: number; | ||
|
|
||
| /** TODO: Doesn't exist in the app */ |
There was a problem hiding this comment.
Let's remove if it's not used, same for other TODOs like this
fabioh8010
left a comment
There was a problem hiding this comment.
Looking real good, but there are still many properties with TODOs, let's solve them
- Confirming if they need to be there or just remove them
- For the testing properties, remove TODO word and make it clear is used for testing purposes
- For the ones that could be a different type, either test it or leave as it is
src/types/onyx/OriginalMessage.ts
Outdated
| type OriginalMessageApproved = { | ||
| actionName: typeof CONST.REPORT.ACTIONS.TYPE.APPROVED; | ||
|
|
||
| /** TODO: I think the type should match the scructure of `originalMessage` in `buildOptimisticApprovedReportAction` */ |
There was a problem hiding this comment.
Let's test this or if not possible, leave unknown
src/types/onyx/OriginalMessage.ts
Outdated
|
|
||
| /** Model of original message of `reimbursed dequeued` report action */ | ||
| type ReimbursementDeQueuedMessage = { | ||
| /** TODO: I'd replace this type with `ValueOf<typeof CONST.REPORT.CANCEL_PAYMENT_REASONS>` */ |
src/types/onyx/OriginalMessage.ts
Outdated
| /** TODO: Doesn't exist in the app */ | ||
| edits?: string[]; | ||
|
|
||
| /** TODO: Doesn't exist in the app */ | ||
| childReportID?: string; | ||
|
|
||
| /** TODO: Doesn't exist in the app */ | ||
| isDeletedParentAction?: boolean; | ||
|
|
||
| /** TODO: Doesn't exist in the app */ | ||
| flags?: Record<FlagSeverityName, FlagSeverity[]>; | ||
|
|
||
| /** TODO: Doesn't exist in the app */ | ||
| moderationDecisions?: Decision[]; | ||
|
|
||
| /** TODO: Only used in tests */ | ||
| whisperedTo: number[]; | ||
|
|
||
| /** TODO: Doesn't exist in the app */ | ||
| reactions?: Reaction[]; |
There was a problem hiding this comment.
Let's confirm if they have some purpose or just remove from the App, expect whisperedTo (change the comment to remove TODO)
src/types/onyx/OriginalMessage.ts
Outdated
| /** TODO: I think this type could be changed to `ValueOf<typeof CONST.REPORT.ACTIONABLE_MENTION_JOIN_WORKSPACE_RESOLUTION>` */ | ||
| /** What was the invited user decision */ | ||
| choice: string; | ||
|
|
||
| /** TODO: Doesn't exist in the app */ | ||
| email: string; | ||
|
|
||
| /** TODO: Doesn't exist in the app */ | ||
| inviterEmail: string; | ||
|
|
||
| /** TODO: Only used in tests */ | ||
| lastModified: string; | ||
|
|
||
| /** TODO: Doesn't exist in the app */ | ||
| policyID: string; |
There was a problem hiding this comment.
Same for the TODOs, confirm to remove the unused, remove TODO word from testing ones
src/types/onyx/OriginalMessage.ts
Outdated
| /** ID of the transaction */ | ||
| transactionID: string; | ||
|
|
||
| /** TODO: Only used in tests */ |
There was a problem hiding this comment.
Remove TODO word from testing ones
src/types/onyx/OriginalMessage.ts
Outdated
| type OriginalMessageReimbursementDequeued = { | ||
| actionName: typeof CONST.REPORT.ACTIONS.TYPE.REIMBURSEMENT_DEQUEUED; | ||
|
|
||
| /** TODO: I think this type should be `ReimbursementDeQueuedMessage` */ |
There was a problem hiding this comment.
Either test it or leave as it is
| type TaxCode = { | ||
| /** TODO: Not used in app */ | ||
| totalTaxRateVal: string; | ||
|
|
||
| /** TODO: Not used in app */ | ||
| simpleName: string; | ||
|
|
||
| /** TODO: Not used in app */ | ||
| taxCodeRef: string; | ||
|
|
||
| /** TODO: Not used in app */ | ||
| taxRateRefs: Record<string, string>; | ||
|
|
||
| /** TODO: Not used in app */ | ||
| /** Name of the tax code */ | ||
| name: string; | ||
| }; |
There was a problem hiding this comment.
Nothing is used here? Is this type even being used at all?
src/types/onyx/Policy.ts
Outdated
| * Data imported from QuickBooks Online. | ||
| */ | ||
| type QBOConnectionData = { | ||
| /** TODO: I think this value can be changed to `ValueOf<CONST.COUNTRY>` */ |
There was a problem hiding this comment.
Let's test it or leave as it is
…-remaining-onyx-types # Conflicts: # src/types/onyx/Policy.ts
…-remaining-onyx-types
|
@cead22 do you know anyone that can help by providing descriptions to the remaining Xero and Quickbooks online type declarations? Thanks 🙌 |
|
For properties in Policy that are related to QBO and Xero, I can add comments to them in a follow up PP as discussed here Issue created -> #43033 |
…-remaining-onyx-types # Conflicts: # src/types/onyx/OriginalMessage.ts # src/types/onyx/Transaction.ts
fabioh8010
left a comment
There was a problem hiding this comment.
@pac-guerreiro There are still TODOs on these three files, let's get them done and open the PR asap
src/libs/ReportActionsUtils.ts
Outdated
| function isActionableJoinRequestPending(reportID: string): boolean { | ||
| const sortedReportActions = getSortedReportActions(Object.values(getAllReportActions(reportID))); | ||
| const findPendingRequest = sortedReportActions.find((reportActionItem) => isActionableJoinRequest(reportActionItem) && reportActionItem.originalMessage.choice === ''); | ||
| const findPendingRequest = sortedReportActions.find((reportActionItem) => isActionableJoinRequest(reportActionItem) && reportActionItem.originalMessage.choice === '' as ValueOf<typeof CONST.REPORT.ACTIONABLE_MENTION_JOIN_WORKSPACE_RESOLUTION>); |
There was a problem hiding this comment.
Lets create a type for ValueOf<typeof CONST.REPORT.ACTIONABLE_MENTION_JOIN_WORKSPACE_RESOLUTION> and use it here.
| if (!isActionableWhisper && (!ReportActionsUtils.isActionableJoinRequest(action) || action.originalMessage.choice !== '')) { | ||
| if ( | ||
| !isActionableWhisper && | ||
| (!ReportActionsUtils.isActionableJoinRequest(action) || action.originalMessage.choice !== ('' as ValueOf<typeof CONST.REPORT.ACTIONABLE_MENTION_JOIN_WORKSPACE_RESOLUTION>)) |
…-remaining-onyx-types # Conflicts: # src/pages/home/report/ReportFooter.tsx
…-remaining-onyx-types # Conflicts: # src/types/onyx/IOU.ts
…-remaining-onyx-types
…r/39129-add-comments-to-remaining-onyx-types
mountiny
left a comment
There was a problem hiding this comment.
@pac-guerreiro Thank you very much, this must have been hard to put together. I am going to merge this now to avoid conflicts but please address my comments in a new PR
| amount: number; | ||
|
|
||
| /** Optional comment */ | ||
| comment?: string; |
There was a problem hiding this comment.
NAB: I think the comment is optional so it can be an empty string but the property would be returned always
| comment?: string; | |
| comment: string; |
| /** Name of the decision */ | ||
| decision: DecisionName; | ||
|
|
||
| /** When was the decision name */ |
There was a problem hiding this comment.
| /** When was the decision name */ | |
| /** When was the decision made */ |
| /** Currency of the approved expense amount */ | ||
| currency: string; | ||
|
|
||
| /** Report ID of the expense */ |
There was a problem hiding this comment.
I think we have to be a bit careful with use of expense / expense report. Expense = transaction and you can have a transaction thread.
In this case the report action refers to the expense report so we should make it clear to remove any doubts
| /** Report ID of the expense */ | |
| /** Report ID of the expense report*/ |
|
|
||
| /** Content of the original message */ | ||
| originalMessage: { | ||
| /** Approved expense amount */ |
There was a problem hiding this comment.
| /** Approved expense amount */ | |
| /** Approved expense report amount */ |
| /** Approved expense amount */ | ||
| amount: number; | ||
|
|
||
| /** Currency of the approved expense amount */ |
There was a problem hiding this comment.
| /** Currency of the approved expense amount */ | |
| /** Currency of the approved expense report amount */ |
|
|
||
| /** Model of a transaction violation */ | ||
| type TransactionViolation = { | ||
| /** Type of transaction violation ('violation', 'notice', 'warning', ...) */ |
There was a problem hiding this comment.
Lets add these into CONST to get stricter here
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: NativeiOS: mWeb SafariMacOS: Chrome / SafariMacOS: Desktop |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to production by https://github.com/luacmartins in version: 1.4.81-11 🚀
|
Details
This PR aims to add descriptions for every Onyx type and property in the codebase. It also add a ESLint rule to enforces every Onyx type and its properties to have a comment explaining its purpose.
As discussed here, QBO and Xero typings will be handled in a follow up issue.
Fixed Issues
$ #39129
PROPOSAL: N/A
Tests
N/A
Offline tests
N/A
QA Steps
N/A
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
N/A
Android: mWeb Chrome
N/A
iOS: Native
N/A
iOS: mWeb Safari
N/A
MacOS: Chrome / Safari
N/A
MacOS: Desktop
N/A