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

fix: remove ts-ignore by converting to string[] #14622

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

kaleem68
Copy link
Contributor

What does this PR do?

It removes ts-ignore by combining if and else if conditions into if condition.

Fixes #14621

The solution follows a suggestion mentioned in the suggestion of #14621

Screenshot 2024-04-17 at 4 14 01 AM

ts ignore warning is removed successfully.

Type of change

  • Chore (refactoring code, technical debt, workflow improvements)

Copy link

vercel bot commented Apr 16, 2024

@kaleem68 is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@graphite-app graphite-app bot added the community Created by Linear-GitHub Sync label Apr 16, 2024
@graphite-app graphite-app bot requested a review from a team April 16, 2024 23:14
@dosubot dosubot bot added core area: core, team members only platform Anything related to our platform plan labels Apr 16, 2024
Copy link
Contributor

github-actions bot commented Apr 16, 2024

Thank you for following the naming conventions! 🙏 Feel free to join our discord and post your PR link.

@graphite-app graphite-app bot requested a review from a team April 16, 2024 23:15
Copy link

graphite-app bot commented Apr 16, 2024

Graphite Automations

"Add community label" took an action on this PR • (04/16/24)

1 label was added to this PR based on Keith Williams's automation.

"Add consumer team as reviewer" took an action on this PR • (04/16/24)

1 reviewer was added to this PR based on Keith Williams's automation.

"Add platform team as reviewer" took an action on this PR • (04/16/24)

1 reviewer was added to this PR based on Keith Williams's automation.

Copy link
Contributor

github-actions bot commented Apr 16, 2024

📦 Next.js Bundle Analysis for @calcom/web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

Sixty-two Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load % of Budget (350 KB)
/apps 275.71 KB 504.14 KB 144.04% (🟢 -0.29%)
/apps/[slug] 293.89 KB 522.32 KB 149.23% (🟢 -0.15%)
/apps/[slug]/[...pages] 584.43 KB 812.86 KB 232.25% (🟢 -0.31%)
/apps/categories 253.62 KB 482.04 KB 137.73% (🟢 -0.31%)
/apps/categories/[category] 258.4 KB 486.83 KB 139.09% (🟢 -0.17%)
/availability 461.74 KB 690.17 KB 197.19% (🟢 -0.26%)
/availability/[schedule] 407.98 KB 636.4 KB 181.83% (🟢 -0.30%)
/bookings/[status] 321.37 KB 549.79 KB 157.08% (🟢 -0.30%)
/enterprise 253.68 KB 482.1 KB 137.74% (🟢 -0.30%)
/event-types 553.8 KB 782.22 KB 223.49% (🟢 -0.26%)
/event-types/[type] 432.68 KB 661.11 KB 188.89% (🟢 -0.30%)
/getting-started/[[...step]] 404.91 KB 633.33 KB 180.95% (🟡 +0.25%)
/insights 472.09 KB 700.51 KB 200.15% (🟢 -0.31%)
/more 253.18 KB 481.61 KB 137.60% (🟢 -0.30%)
/settings/admin 259.5 KB 487.93 KB 139.41% (🟢 -0.29%)
/settings/admin/apps 272.57 KB 501 KB 143.14% (🟢 -0.22%)
/settings/admin/apps/[category] 272.55 KB 500.98 KB 143.14% (🟢 -0.22%)
/settings/admin/flags 263.31 KB 491.73 KB 140.50% (🟢 -0.30%)
/settings/admin/impersonation 259.8 KB 488.23 KB 139.49% (🟢 -0.29%)
/settings/admin/orgMigrations/_OrgMigrationLayout 248.09 KB 476.52 KB 136.15% (🟢 -0.29%)
/settings/admin/orgMigrations/moveUserToOrg 316.78 KB 545.2 KB 155.77% (🟢 -0.15%)
/settings/admin/organizations 261.38 KB 489.81 KB 139.95% (🟢 -0.30%)
/settings/admin/organizations/[id]/edit 260.05 KB 488.48 KB 139.57% (🟢 -0.30%)
/settings/admin/users 262.15 KB 490.57 KB 140.16% (🟢 -0.29%)
/settings/admin/users/[id]/edit 390.43 KB 618.85 KB 176.82% (🟢 -0.23%)
/settings/admin/users/add 390.09 KB 618.52 KB 176.72% (🟢 -0.24%)
/settings/billing 259.71 KB 488.13 KB 139.47% (🟢 -0.29%)
/settings/developer/api-keys 264.08 KB 492.51 KB 140.72% (🟢 -0.30%)
/settings/developer/webhooks 264.21 KB 492.64 KB 140.75% (🟢 -0.29%)
/settings/developer/webhooks/[id] 265.67 KB 494.1 KB 141.17% (🟢 -0.15%)
/settings/developer/webhooks/new 265.72 KB 494.15 KB 141.18% (🟢 -0.14%)
/settings/my-account/appearance 312.08 KB 540.51 KB 154.43% (🟢 -0.33%)
/settings/my-account/conferencing 271.92 KB 500.34 KB 142.96% (🟢 -0.20%)
/settings/my-account/general 377.27 KB 605.69 KB 173.06% (🟢 -0.33%)
/settings/my-account/out-of-office 264.69 KB 493.12 KB 140.89% (🟢 -0.29%)
/settings/my-account/profile 402.94 KB 631.37 KB 180.39% (🟢 -0.29%)
/settings/organizations/[id]/onboard-members 170.55 KB 398.97 KB 113.99% (🟢 -0.23%)
/settings/organizations/appearance 283.23 KB 511.66 KB 146.19% (🟢 -0.32%)
/settings/organizations/billing 259.74 KB 488.17 KB 139.48% (🟢 -0.30%)
/settings/organizations/platform/oauth-clients 262.03 KB 490.45 KB 140.13% (🟢 -0.29%)
/settings/organizations/platform/oauth-clients/create 262.13 KB 490.55 KB 140.16% (🟢 -0.30%)
/settings/organizations/privacy 265.09 KB 493.52 KB 141.01% (🟢 -0.24%)
/settings/organizations/profile 394.45 KB 622.88 KB 177.97% (🟢 -0.59%)
/settings/organizations/sso 270.35 KB 498.78 KB 142.51% (🟢 -0.26%)
/settings/organizations/teams/other 260.57 KB 489 KB 139.71% (🟢 -0.29%)
/settings/organizations/teams/other/[id]/appearance 272.24 KB 500.66 KB 143.05% (🟢 -0.29%)
/settings/organizations/teams/other/[id]/members 267.04 KB 495.47 KB 141.56% (🟢 -0.29%)
/settings/organizations/teams/other/[id]/profile 466.06 KB 694.48 KB 198.42% (🟢 -0.36%)
/settings/security/impersonation 264.89 KB 493.32 KB 140.95% (🟢 -0.29%)
/settings/security/sso 269.76 KB 498.18 KB 142.34% (🟢 -0.22%)
/settings/security/two-factor-auth 268.36 KB 496.78 KB 141.94% (🟢 -0.29%)
/settings/teams 259.24 KB 487.67 KB 139.33% (🟢 -0.29%)
/settings/teams/[id]/appearance 272.22 KB 500.65 KB 143.04% (🟢 -0.28%)
/settings/teams/[id]/billing 259.74 KB 488.17 KB 139.48% (🟢 -0.30%)
/settings/teams/[id]/members 379.01 KB 607.44 KB 173.55% (🟢 -0.34%)
/settings/teams/[id]/onboard-members 169.73 KB 398.15 KB 113.76% (🟢 -0.23%)
/settings/teams/[id]/profile 466.9 KB 695.33 KB 198.67% (🟢 -0.36%)
/settings/teams/new 196.85 KB 425.28 KB 121.51% (🟢 -0.31%)
/teams 253.41 KB 481.83 KB 137.67% (🟢 -0.31%)
/upgrade 253.53 KB 481.96 KB 137.70% (🟢 -0.30%)
/workflows 284.69 KB 513.11 KB 146.60% (🟢 -0.32%)
/workflows/[workflow] 407.05 KB 635.48 KB 181.57% (🟢 -0.32%)
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

The "Budget %" column shows what percentage of your performance budget the First Load total takes up. For example, if your budget was 100kb, and a given page's first load size was 10kb, it would be 10% of your budget. You can also see how much this has increased or decreased compared to the base branch of your PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this. If you see "+/- <0.01%" it means that there was a change in bundle size, but it is a trivial enough amount that it can be ignored.

@emrysal
Copy link
Contributor

emrysal commented Apr 19, 2024

Closing this as it's possible that the parameter is an object - but the typescript is a little bit hard due to constructUri overloading.

@emrysal emrysal closed this Apr 19, 2024
@kaleem68
Copy link
Contributor Author

@emrysal whats would be ideal solution then! is it for endpoint.constructUri to accept string[] and record<string,string>

In original code its using //ts ignore and I want to git rid of //ts ignore

Let me know possible suggestion so i can try to fix it

@emrysal emrysal reopened this Apr 19, 2024
@emrysal
Copy link
Contributor

emrysal commented Apr 19, 2024

@kaleem68 I committed in a potential fix for your consideration also

type EndpointDeclaration<ParamsType extends Record<string, string> | string[] = string[]> =
| StaticUriEndpoint
| DynamicUriEndpoint<ParamsType>;
type EndpointDeclaration = StaticUriEndpoint | DynamicUriEndpoint;
Copy link
Contributor Author

@kaleem68 kaleem68 Apr 20, 2024

Choose a reason for hiding this comment

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

Suggestion

// Define a type to avoid verbosity
type StrArrOrRecordStrStr = string[] | Record<string, string>;

auth: "public",
apiVersion: version,
});
const constructUri = (
Copy link
Contributor Author

@kaleem68 kaleem68 Apr 20, 2024

Choose a reason for hiding this comment

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

constructUri params can be simplified

Suggestion

const constructUri = (endpointData: EndpointDeclaration, params: StrArrOrRecordStrStr) => {
  if (endpointData.constructUriFromObject && isParamsRecord(params)) {
    return endpointData.constructUriFromObject(params);
  }
  if (endpointData.constructUriFromArray && Array.isArray(params)) {
    return endpointData.constructUriFromArray(params);
  }
  throw new Error("Invalid parameter type for dynamic endpoint.");
};

Copy link
Contributor Author

@kaleem68 kaleem68 Apr 20, 2024

Choose a reason for hiding this comment

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

Update params for getEndpointData

Suggestion

export const getEndpointData = (
  endpoint: Endpoints,
  params?: StrArrOrRecordStrStr
)

Copy link
Contributor Author

@kaleem68 kaleem68 left a comment

Choose a reason for hiding this comment

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

@emrysal I have made a few suggestions based on your commit.

I would be happy if we could get one more review from calcom team member on your changes.

Copy link
Contributor

github-actions bot commented May 5, 2024

This PR is being marked as stale due to inactivity.

@github-actions github-actions bot added the Stale label May 5, 2024
@keithwillcode keithwillcode removed the platform Anything related to our platform plan label May 7, 2024
@github-actions github-actions bot removed the Stale label May 8, 2024
@keithwillcode keithwillcode added this to the v4.1 milestone May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Created by Linear-GitHub Sync core area: core, team members only 💻 refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Simplify logic by removing unnecessary // ts-ignore
3 participants