-
Notifications
You must be signed in to change notification settings - Fork 3k
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 'SettingsWalletDetails' page to TypeScript #34257
Conversation
@cubuspl42 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Oh my, a lot of changes. |
I updated the PR, there're many places that use |
Please update the title of this PR to |
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
onSuccessfulKYC={(_iouPaymentType: string, source: string) => navigateToWalletOrTransferBalancePage(source)} | ||
onSelectPaymentMethod={(selectedPaymentMethod: string) => { | ||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing | ||
if (hasActivatedWallet || selectedPaymentMethod !== CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not ??
? (check all cases - in all of them you can use ??
instead of disabling rules)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned here, we need to preserve ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this specific linter silencing needed?
The typing is: const hasActivatedWallet: boolean
, so why would it trigger the linter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that all 3 cases of // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
left in the code are related to using ||
with trivial booleans. Are they actually necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's necessary. We all know false || true
is different from false ?? true
. So I believe we need || in these cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be on the same page, I'm asking whether this specific linter silencing is necessary, not whether using the ||
operator is necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, aren't both sides simply of type boolean
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, understand your mean. I removed these linters silencing
Please resolve conflicts |
I think there's some confusion with
When we work with (potentially) empty strings and (potentially) zero-valued numbers, etc., So, when migrating, you must ask yourself whether we're working with values like |
@cubuspl42 Thanks! 💯 Ideally we should use |
Waiting for response from #33714 (comment) |
@tienifr Go ahead and adjust KYCWall type 😄 |
@tienifr I can see we have good progress here! 👍 Please reply to all threads |
TypeScript Checks are failing |
@tienifr Bad luck; conflicts |
const assignedCards = _.chain(cardList) | ||
// Filter by physical, active cards associated with a domain | ||
.filter((card) => !card.isVirtual && card.domainName && CONST.EXPENSIFY_CARD.ACTIVE_STATES.includes(card.state)) | ||
.filter((card) => !card.isVirtual && !!card.domainName && CONST.EXPENSIFY_CARD.ACTIVE_STATES.includes(card.state ?? 0)) | ||
.sortBy((card) => !CardUtils.isExpensifyCard(card.cardID)) | ||
.value(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although the name is a bit weird, actually a standard equivalent is toSorted(compareFn)
. Let's use that!
@@ -318,10 +280,12 @@ function PaymentMethodList({ | |||
icon={item.icon} | |||
disabled={item.disabled} | |||
displayInDefaultIconColor | |||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing | |||
iconHeight={item.iconHeight || item.iconSize} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@filip-solecki What do you think? Should we reflect the old code directly, or assume that the original authors only meant to check for undefined
with ||
?
@tienifr Did you search for the usages? Do we have a convention to pass 0
as height/length meaning "not set"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imo we should check only for undefined, 0 should be passed intentionally, but don't know what is the convention you mentioned
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean that there's sometimes a convention that 0 could mean "not set", like in the case of some IDs. Then, silencing the linter would make sense, and we could use ||
on purpose. If it's not the case, I think we should migrate to ??
and not silence the linter in this specific case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tienifr Let's adjust as @cubuspl42 suggested, and let's continue the work to ship it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for bumping, and I agree that we should wrap things up!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been OOO. I'll handle this tomorrow morning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated. TY!
Conflicts |
@cubuspl42 Thanks for pointing that out. I'm updating the PR |
@cubuspl42 I resolved the conflicts |
Please take a look: #34257 (comment) |
@tienifr Bump 😅 |
I'm updating |
@cubuspl42 @blazejkustra updated to use toSorted |
@tienifr Linter. |
Reviewer Checklist
Screenshots/VideosAndroid: Nativewallet-ts-android-compressed.mp4Android: mWeb Chromewallet-ts-android-web-compressed.mp4iOS: Nativewallet-ts-ios-compressed.mp4iOS: mWeb Safariwallet-ts-ios-web-compressed.mp4MacOS: Chrome / Safariwallet-ts-web-converted.mp4MacOS: Desktop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the linter and let's finally merge this
fixed |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
.sortBy((card) => !CardUtils.isExpensifyCard(card.cardID)) | ||
.value(); | ||
.filter((card) => !card.isVirtual && !!card.domainName && CONST.EXPENSIFY_CARD.ACTIVE_STATES.includes(card.state ?? 0)) | ||
.toSorted((card1, card2) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this fully tested on all platforms? I am getting crash on iOS
https://stackoverflow.com/questions/76006398/tosorted-works-only-in-a-browser
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The platforms were tested, I wonder if it's due to another recently merged PR which conflicts with the changes (not a code conflict, but something that breaks due to these TS changes)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible that this code path wasn't triggered during our tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a conflict; this method isn't available on iOS. I'm not sure why we didn't catch this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fixing this right now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edit: I have some weird issues with ESLint on this PR, likely because of the changes in packages-lock.json
. I don't have time to fix that, I'm pivoting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we just use sort
? I tested and verified it achieved the same result. sort
also returns the sorted result, the only difference is that it's sorted in-place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because using sort
together with React can lead to very difficult to debug bugs (as it's mutating the original array). I've seen buggy code related to sort
in the Expensify code.
Using sort
in this specific case would work, though. Still, I'd personally prefer to have some linter rule completely banning the usage of sort
inside React components.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I closed the first PR (see explanation).
Second PR, switching back to _.sortBy
: #37078
🚀 Deployed to staging by https://github.com/Julesssss in version: 1.4.44-0 🚀
|
🚀 Deployed to production by https://github.com/puneetlath in version: 1.4.44-13 🚀
|
Details
Fixed Issues
$ #32001
PROPOSAL: NA
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Screen.Recording.2024-01-11.at.16.02.25.mov
Android: mWeb Chrome
Screen.Recording.2024-01-11.at.15.32.00.mov
iOS: Native
Screen.Recording.2024-01-11.at.11.38.33.mov
iOS: mWeb Safari
Screen.Recording.2024-01-11.at.11.26.41.mov
MacOS: Chrome / Safari
Screen.Recording.2024-01-11.at.11.21.23.mov
MacOS: Desktop
Screen.Recording.2024-01-11.at.11.28.24.mov