fix(NuxtLinkLocale): allow string paths in to prop (fixes #4005)#4006
fix(NuxtLinkLocale): allow string paths in to prop (fixes #4005)#4006houtanrocky wants to merge 2 commits into
to prop (fixes #4005)#4006Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThe Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install timed out. The project may have too many dependencies for the sandbox. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thank you for your PR! Rejecting path strings when The docs showing path usage predate typed routes, this should be resolved by #4020 which updates the examples to use named routes and documents the rationale. |
🔗 Linked issue
resolves #4005
📚 Description
Problem
The
NuxtLinkLocalecomponent currently rejects plain string paths passed to thetoprop, even though the documentation shows examples liketo="/".TypeScript reports:
This is because the
toprop is incorrectly typed asRouteLocationNamedI18n, a generated type that only accepts named route objects.Solution
Change the
toprop type toRouteLocationRaw(the unionstring | RouteLocation), which matches:<NuxtLink>component'stoprop typeChanges
type NuxtLinkLocaleProps<CustomProp extends boolean = false> = Omit<NuxtLinkProps<CustomProp>, 'to'> & { - to?: import('vue-router').RouteLocationNamedI18n + to?: import('vue-router').RouteLocationRaw locale?: Locale }Impact
RouteLocationRawis a supertype; all existing named‑route usage remains validSummary by CodeRabbit
NuxtLinkLocalerouting.hrefvalues under theprefixrouting strategy when typed pages are enabled.