Skip to content

chore: ensure compat type definitions do not break existing types#11741

Merged
zomars merged 2 commits intocalcom:mainfrom
codemod:intuita/compatTypes
Oct 10, 2023
Merged

chore: ensure compat type definitions do not break existing types#11741
zomars merged 2 commits intocalcom:mainfrom
codemod:intuita/compatTypes

Conversation

@grzpab
Copy link
Copy Markdown
Contributor

@grzpab grzpab commented Oct 6, 2023

What does this PR do?

This PR introduces changes to handle nullable return value from Next.js hooks (useSearchParams, useParams, usePathname and useRouter).
If you add the app directory to the web directory and run yarn build, the types will be updated by Next.js builder/plugin and the projects will then include the compat type definitions provided by Next.js.

This mechanism is coded here: https://github.com/vercel/next.js/blob/524b31513a58e58e15862ac8aa3f27da8a47a267/packages/next/src/lib/typescript/writeAppTypeDeclarations.ts#L54

The example compat type definition is here: https://github.com/vercel/next.js/blob/524b31513a58e58e15862ac8aa3f27da8a47a267/packages/next/navigation-types/compat/navigation.d.ts

Fixes # (issue)
There is no reported issue, this problem becomes visible only when the app directory is added and someone runs yarn type-check.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Chore (refactoring code, technical debt, workflow improvements)

How should this be tested?

This requires the entire app check, because I touched

  • fromEntriesWithDuplicateKeys in packages/lib/hooks/useRouterQuery.ts which is used in useRouterQuery, which in turn is used in 19 pages
  • the metadata generating utilities (packages/lib/next-seo.config.ts)

Checklist

  • I haven't checked if my PR needs changes to the documentation
  • I haven't checked if my changes generate no new warnings

@vercel
Copy link
Copy Markdown

vercel Bot commented Oct 6, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
api ❌ Failed (Inspect) Oct 10, 2023 9:53pm
ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 10, 2023 9:53pm

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Oct 6, 2023

CLA assistant check
All committers have signed the CLA.

@vercel
Copy link
Copy Markdown

vercel Bot commented Oct 6, 2023

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

A member of the Team first needs to authorize it.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Oct 6, 2023

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Oct 6, 2023

📦 Next.js Bundle Analysis for @calcom/web

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

This PR introduced no changes to the JavaScript bundle! 🙌

Copy link
Copy Markdown
Contributor

@zomars zomars left a comment

Choose a reason for hiding this comment

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

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants