Skip to content

Conversation

@max-programming
Copy link

@max-programming max-programming commented Oct 27, 2025

Description

This PR enables Next.js typed routes for the marigold ui docs. Now there is better intellisense for href in Link component and router.push and router.replace methods

image

Test Instructions:

Go to usage of any Link component and pass in a non-existing href, it will throw a typeerror

Reviewers:

@marigold-ui/developer

Pull Request Checklist:

  • Marigold docs and Storybook Preview is available
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Added/Updated documentation (if it already exists for this component).
  • Updated visual regression tests (only necessary when ui changes in the PR)

@changeset-bot
Copy link

changeset-bot bot commented Oct 27, 2025

⚠️ No Changeset found

Latest commit: 9635109

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Oct 27, 2025

@max-programming is attempting to deploy a commit to the Marigold Team on Vercel.

A member of the Team first needs to authorize it.

@max-programming max-programming marked this pull request as draft October 27, 2025 13:52
@max-programming max-programming marked this pull request as ready for review October 27, 2025 14:03
@sebald
Copy link
Member

sebald commented Oct 28, 2025

Thanks for the PR but as Route casting is certainly not the correct approach.

@sebald sebald closed this Oct 28, 2025
@max-programming
Copy link
Author

max-programming commented Oct 28, 2025

@sebald actually there was no other way than this because a lot of href's came from contentlayer. Only for those and some mdx routes is where I have as Route

I'd suggest re-consider and review the code. I've also made the useGoto hook fully typesafe with a complex type to accept routes without a slash

Btw the Route type is entirely typesafe. So any props with the Route type are also strictly typed. It's not like the any type

@sebald
Copy link
Member

sebald commented Oct 29, 2025

@max-programming Hey, thanks for coming back to us. Yeah the latest changes look better. This is kind of what I was referring to in my comment. Rather than use type assertion at the end, the types should be safe from the start.

@max-programming
Copy link
Author

@sebald Awesome! Thanks for taking a deeper look. Also try running it locally (running it generates the types in the .next directory)

And do let me know if I am missing something out here. After all we're here to learn and grow 🙂

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.

2 participants