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 'getPlaidLinkTokenParameters' lib to TypeScript #27527

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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: 0 additions & 3 deletions src/libs/getPlaidLinkTokenParameters/index.android.js

This file was deleted.

9 changes: 9 additions & 0 deletions src/libs/getPlaidLinkTokenParameters/index.android.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import CONST from '../../CONST';
import GetPlaidLinkTokenParameters from './types';

const getPlaidLinkTokenParameters: GetPlaidLinkTokenParameters = () => ({
// eslint-disable-next-line @typescript-eslint/naming-convention
android_package: CONST.ANDROID_PACKAGE_NAME,
});

export default getPlaidLinkTokenParameters;
3 changes: 0 additions & 3 deletions src/libs/getPlaidLinkTokenParameters/index.ios.js

This file was deleted.

9 changes: 9 additions & 0 deletions src/libs/getPlaidLinkTokenParameters/index.ios.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import CONFIG from '../../CONFIG';
import GetPlaidLinkTokenParameters from './types';

const getPlaidLinkTokenParameters: GetPlaidLinkTokenParameters = () => ({
// eslint-disable-next-line @typescript-eslint/naming-convention
redirect_uri: `${CONFIG.EXPENSIFY.NEW_EXPENSIFY_URL}partners/plaid/oauth_ios`,
});

export default getPlaidLinkTokenParameters;
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import ROUTES from '../../ROUTES';
import CONFIG from '../../CONFIG';
import GetPlaidLinkTokenParameters from './types';

export default () => {
const getPlaidLinkTokenParameters: GetPlaidLinkTokenParameters = ()=> {
VickyStash marked this conversation as resolved.
Show resolved Hide resolved
const bankAccountRoute = window.location.href.includes('personal') ? ROUTES.BANK_ACCOUNT_PERSONAL : ROUTES.BANK_ACCOUNT;

// eslint-disable-next-line @typescript-eslint/naming-convention
return {redirect_uri: `${CONFIG.EXPENSIFY.NEW_EXPENSIFY_URL}${bankAccountRoute}`};
};

export default getPlaidLinkTokenParameters;
14 changes: 14 additions & 0 deletions src/libs/getPlaidLinkTokenParameters/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
type PlaidLinkTokenParameters = {
// eslint-disable-next-line @typescript-eslint/naming-convention
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB but why are we suppressing this several times in this PR? Would it make sense to abide by this convention as part of this PR or would that require a lot of updated that are out of scope for this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cead22 This convention is more of an exception for this specific case, so I think we shouldn't apply it everywhere.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you help me understand this a little better? I don't think it's truly an exception since there's 5 occurrences in this PR, which is very small.

What are the reasons for not updating the variable names to meet the naming convention?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cead22 These variables are parameters that are later sent to the API
API.read('OpenPlaidBankLogin', params, {optimisticData});

So even if we rename it here, then before sending it to the API, we will need to do something like {redirect_uri: redirectUri}, and it also can cause a convention warning

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, so I think the correct way to complete this issue is

  • Update the backend to accept redirectURI and redirect_uri (cc @nkuoch)
  • Update JS to use the right naming convention

If we don't do this, then we'll continue breaking our conventions forever, and continue adding exceptions, which defeats the purpose of having them.

We need to think about our code holistically and continuously update the code surrounding the code we edit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cead22 Just want to confirm, have you also updated android_package field to be accepted as both android_package and androidPackage?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦 I did not, I'll do that now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cead22 Have API updates been published?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, they were deployed to production yesterday!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cead22 Thank you! I've updated the PR

android_package?: string;

// eslint-disable-next-line @typescript-eslint/naming-convention
redirect_uri?: string;

allowDebit?: boolean;
bankAccountID?: number;
VickyStash marked this conversation as resolved.
Show resolved Hide resolved
};

type GetPlaidLinkTokenParameters = () => PlaidLinkTokenParameters;

export default GetPlaidLinkTokenParameters;
Loading