-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 PlaidLink directory to TypeScript #30915
[TS Migration] Migrate PlaidLink directory to TypeScript #30915
Conversation
Log.info('[PlaidLink] Handled Plaid Event: ', false, event); | ||
props.onEvent(event.eventName, event.metadata); | ||
usePlaidEmitter((event: LinkEvent) => { | ||
Log.info('[PlaidLink] Handled Plaid Event: ', false, event.eventName); |
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.
Are you sure there should be event.eventName
here?
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.
If you try to pass the whole event
object, it produces the following error:
Argument of type 'LinkEvent' is not assignable to parameter of type 'Parameters | undefined'.
Type 'LinkEvent' is not assignable to type 'Record<string, unknown>'.
Do you think we should keep it as it is or maybe JSON.stringify
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.
Related to microsoft/TypeScript#15300. There is no correct way to fix. We can however apply a workaround:
- Pass
{...event}
toLog.info
- Or change event type (convert interface to type)
event: Pick<LinkEvent, keyof LinkEvent>
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.
Done (1st option)
}); | ||
useEffect(() => { | ||
props.onEvent(CONST.BANK_ACCOUNT.PLAID.EVENTS_NAME.OPEN, {}); | ||
onEvent(CONST.BANK_ACCOUNT.PLAID.EVENTS_NAME.OPEN); |
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 know that this argument you've removed was probably unnecessary, but please make sure it doesn't cause any regressions.
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.
This may actually cause a crash. Please do one of the following:
- Update AddPlaidBankAccount to take into account the possibility of metadata being undefined (cannot access metadata.error_code)
- Revert this change and add a dummy object (+update
types.ts
to mark metadata as required)
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.
Done (1st option)
Before making this PR ready for review please add QA steps! |
@ 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] |
@s77rt can you please do checklist on this PR? |
Log.info('[PlaidLink] Handled Plaid Event: ', false, event); | ||
props.onEvent(event.eventName, event.metadata); | ||
usePlaidEmitter((event: LinkEvent) => { | ||
Log.info('[PlaidLink] Handled Plaid Event: ', false, event.eventName); |
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.
Related to microsoft/TypeScript#15300. There is no correct way to fix. We can however apply a workaround:
- Pass
{...event}
toLog.info
- Or change event type (convert interface to type)
event: Pick<LinkEvent, keyof LinkEvent>
src/components/PlaidLink/types.ts
Outdated
token: string; | ||
|
||
// Callback to execute once the user taps continue after successfully entering their account information | ||
onSuccess?: (args: {publicToken?: string; metadata: PlaidLinkOnSuccessMetadata | LinkSuccessMetadata}) => void; |
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.
onSuccess?: (args: {publicToken?: string; metadata: PlaidLinkOnSuccessMetadata | LinkSuccessMetadata}) => void; | |
onSuccess?: (args: {publicToken: string; metadata: PlaidLinkOnSuccessMetadata | LinkSuccessMetadata}) => void; |
publicToken is not optional
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.
Done!
src/components/PlaidLink/types.ts
Outdated
onExit?: () => void; | ||
|
||
// Callback to execute whenever a Plaid event occurs | ||
onEvent: (eventName: PlaidLinkStableEvent | string, metadata?: PlaidLinkOnEventMetadata | LinkEventMetadata) => void; |
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.
onEvent: (eventName: PlaidLinkStableEvent | string, metadata?: PlaidLinkOnEventMetadata | LinkEventMetadata) => void; | |
onEvent: (eventName: string, metadata?: PlaidLinkOnEventMetadata | LinkEventMetadata) => void; |
PlaidLinkStableEvent is a string
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
}); | ||
useEffect(() => { | ||
props.onEvent(CONST.BANK_ACCOUNT.PLAID.EVENTS_NAME.OPEN, {}); | ||
onEvent(CONST.BANK_ACCOUNT.PLAID.EVENTS_NAME.OPEN); |
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.
This may actually cause a crash. Please do one of the following:
- Update AddPlaidBankAccount to take into account the possibility of metadata being undefined (cannot access metadata.error_code)
- Revert this change and add a dummy object (+update
types.ts
to mark metadata as required)
@s77rt I applied the changes you suggested, thank you for thorough review! |
@JKobrynski Thanks! Code looks good to me. Working on checklist / tests. I noticed the tests steps are not correct. I think we need to go through the Add bank process not the debit card process. |
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid.movAndroid: mWeb Chromemweb-chrome.moviOS: Nativeios.moviOS: mWeb Safarimweb-safari.movMacOS: Chrome / Safariweb.movMacOS: Desktopdesktop.mov |
@s77rt bump on this one, thanks |
@mountiny Was just waiting for the steps update 😅 |
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!
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
Issue #32079 repro when executing this PR |
🚀 Deployed to production by https://github.com/mountiny in version: 1.4.5-7 🚀
|
Details
Fixed Issues
$
#25068
PROPOSAL: N/A
Tests
Offline tests
N/A
QA Steps
Same as Tests section above
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)/** comment above it */
this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)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
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop