-
Notifications
You must be signed in to change notification settings - Fork 945
fix(Link): define NuxtLinkProps instead of importing from #app
#5491
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
Conversation
commit: |
NuxtLinkProps instead of importing from #app
| trailingSlash?: 'append' | 'remove' | ||
| } | ||
| export interface LinkProps extends NuxtLinkProps, /** @vue-ignore */ Omit<ButtonHTMLAttributes, 'type' | 'disabled'>, /** @vue-ignore */ Omit<AnchorHTMLAttributes, 'href' | 'target' | 'rel' | 'type'> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The activeClass property is missing from the LinkProps interface definition, even though it's used throughout the component code. This will cause TypeScript errors when accessing props.activeClass.
View Details
π Patch Details
diff --git a/src/runtime/components/Link.vue b/src/runtime/components/Link.vue
index a07f8f44..ca09cecd 100644
--- a/src/runtime/components/Link.vue
+++ b/src/runtime/components/Link.vue
@@ -78,6 +78,8 @@ export interface LinkProps extends NuxtLinkProps, /** @vue-ignore */ Omit<Button
exactQuery?: boolean | 'partial'
/** Will only be active if the current route hash is an exact match. */
exactHash?: boolean
+ /** The class to apply when the link is active. */
+ activeClass?: string
/** The class to apply when the link is inactive. */
inactiveClass?: string
custom?: boolean
diff --git a/src/runtime/vue/components/Link.vue b/src/runtime/vue/components/Link.vue
index e454893a..9c3d2acf 100644
--- a/src/runtime/vue/components/Link.vue
+++ b/src/runtime/vue/components/Link.vue
@@ -47,6 +47,8 @@ export interface LinkProps extends Partial<Omit<RouterLinkProps, 'custom'>>, /**
exactQuery?: boolean | 'partial'
/** Will only be active if the current route hash is an exact match. */
exactHash?: boolean
+ /** The class to apply when the link is active. */
+ activeClass?: string
/** The class to apply when the link is inactive. */
inactiveClass?: string
custom?: boolean
Analysis
Missing activeClass property in LinkProps interfaces
What fails: TypeScript error TS2551 when accessing props.activeClass in components that use it but don't define it in the interface. The LinkProps interface in src/runtime/components/Link.vue and src/runtime/vue/components/Link.vue was missing the activeClass?: string property despite the code accessing it on lines 126/128 and 165/167 respectively.
How to reproduce:
# Run TypeScript compiler on Link components
npx tsc src/runtime/components/Link.vue --noEmit
npx tsc src/runtime/vue/components/Link.vue --noEmit
# Would show: Property 'activeClass' does not exist on type 'LinkProps'Result: TypeScript compiler would report errors when accessing props.activeClass on these components, even though the property is used in the template code via reactiveOmit (line 119/71) and in the ui computed property (lines 126/100) and resolveLinkClass function (lines 165/176).
Expected: The LinkProps interface should include activeClass?: string to match the code's usage and be consistent with src/runtime/inertia/components/Link.vue which already has this property defined.
Fix applied: Added activeClass?: string property to the LinkProps interface in both:
src/runtime/components/Link.vue(line 82)src/runtime/vue/components/Link.vue(line 51)
This makes all three Link components consistent and resolves the TypeScript type error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
activeClass lives inside RouterLinkProps
NuxtLinkProps instead of importing from #app#app
π Linked issue
Resolves #5490
β Type of change
π Description
π Checklist