Skip to content

Conversation

danielroe
Copy link
Member

🔗 Linked issue

resolves #33304

📚 Description

this adds some missing props/attrs accepted by <NuxtLink>

@danielroe danielroe self-assigned this Sep 27, 2025
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

pkg-pr-new bot commented Sep 27, 2025

Open in StackBlitz

@nuxt/kit

npm i https://pkg.pr.new/@nuxt/kit@33335

nuxt

npm i https://pkg.pr.new/nuxt@33335

@nuxt/rspack-builder

npm i https://pkg.pr.new/@nuxt/rspack-builder@33335

@nuxt/schema

npm i https://pkg.pr.new/@nuxt/schema@33335

@nuxt/vite-builder

npm i https://pkg.pr.new/@nuxt/vite-builder@33335

@nuxt/webpack-builder

npm i https://pkg.pr.new/@nuxt/webpack-builder@33335

commit: 79d7abd

Copy link

codspeed-hq bot commented Sep 27, 2025

CodSpeed Performance Report

Merging #33335 will not alter performance

Comparing fix/nuxt-link-props (79d7abd) with main (a52ce9a)

Summary

✅ 10 untouched

Copy link

coderabbitai bot commented Sep 27, 2025

Walkthrough

The NuxtLink component typing in packages/nuxt/src/app/components/nuxt-link.ts is updated to augment its props with VNodeProps, AllowedComponentProps, and AnchorHTMLAttributes. The exported component’s constructor type now accepts NuxtLinkProps combined with these standard attributes. The internal DefineSetupFnComponent type is adjusted to propagate the augmented prop set through its setup signature. No runtime logic changes are indicated; modifications are to TypeScript types for the component’s public and internal typings.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title clearly describes the main change of adding missing element and vnode props to the NuxtLink component and uses the conventional commit style to indicate a bug fix scope. It is concise and mentions the affected component, making it easy for a teammate to understand the primary update at a glance. There is no ambiguous or extraneous information in the title.
Linked Issues Check ✅ Passed The changes extend the NuxtLinkProps type with VNodeProps, AllowedComponentProps, and AnchorHTMLAttributes, directly addressing the requirement to accept event listeners and other vnode props from issue #33304. This satisfies the objective of allowing explicit component exports in monorepo setups to pass through standard event listeners without TypeScript errors. The implementation aligns with the linked issue’s request.
Out of Scope Changes Check ✅ Passed All modifications are confined to the nuxt-link.ts file and focus solely on updating the NuxtLink component’s type definitions, with no unrelated or extraneous code changes detected. The diff does not introduce any features or alterations outside the scope of adding missing vnode and HTML element props as specified. Therefore, no out-of-scope changes are present.
Description Check ✅ Passed The pull request description directly refers to the linked issue and succinctly states that missing props and attributes are being added to the NuxtLink component, which matches the changes in the diff. Although brief, it remains on topic and connected to the modifications implemented. It provides enough context to understand the purpose of the update.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/nuxt-link-props

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a52ce9a and 79d7abd.

📒 Files selected for processing (1)
  • packages/nuxt/src/app/components/nuxt-link.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Follow standard TypeScript conventions and best practices

Files:

  • packages/nuxt/src/app/components/nuxt-link.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test-fixtures (windows-latest, built, rspack, async, manifest-on, json, lts/-1)

Comment on lines +529 to 533
}) as unknown as (new<CustomProp extends boolean = false>(props: NuxtLinkProps<CustomProp> & VNodeProps & AllowedComponentProps & AnchorHTMLAttributes) => InstanceType<DefineSetupFnComponent<
NuxtLinkProps<CustomProp> & VNodeProps & AllowedComponentProps & AnchorHTMLAttributes,
[],
SlotsType<NuxtLinkSlots<CustomProp>>
>>) & Record<string, any>
Copy link

@coderabbitai coderabbitai bot Sep 27, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Avoid narrowing href/rel types when intersecting props

Intersecting NuxtLinkProps with AnchorHTMLAttributes collapses the shared keys. In practice, href gets narrowed to string, so passing a route object (which we support and rely on above) now produces a type error. The same happens for rel/target, stripping the null allowance and other specific unions we expose. Please omit the overlapping keys before merging in the anchor attributes.

-  }) as unknown as (new<CustomProp extends boolean = false>(props: NuxtLinkProps<CustomProp> & VNodeProps & AllowedComponentProps & AnchorHTMLAttributes) => InstanceType<DefineSetupFnComponent<
-    NuxtLinkProps<CustomProp> & VNodeProps & AllowedComponentProps & AnchorHTMLAttributes,
+  }) as unknown as (new<CustomProp extends boolean = false>(props: NuxtLinkProps<CustomProp> & VNodeProps & AllowedComponentProps & Omit<AnchorHTMLAttributes, 'href' | 'rel' | 'target'>) => InstanceType<DefineSetupFnComponent<
+    NuxtLinkProps<CustomProp> & VNodeProps & AllowedComponentProps & Omit<AnchorHTMLAttributes, 'href' | 'rel' | 'target'>,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
}) as unknown as (new<CustomProp extends boolean = false>(props: NuxtLinkProps<CustomProp> & VNodeProps & AllowedComponentProps & AnchorHTMLAttributes) => InstanceType<DefineSetupFnComponent<
NuxtLinkProps<CustomProp> & VNodeProps & AllowedComponentProps & AnchorHTMLAttributes,
[],
SlotsType<NuxtLinkSlots<CustomProp>>
>>) & Record<string, any>
}) as unknown as (new<CustomProp extends boolean = false>(
props: NuxtLinkProps<CustomProp> & VNodeProps & AllowedComponentProps & Omit<AnchorHTMLAttributes, 'href' | 'rel' | 'target'>
) => InstanceType<DefineSetupFnComponent<
NuxtLinkProps<CustomProp> & VNodeProps & AllowedComponentProps & Omit<AnchorHTMLAttributes, 'href' | 'rel' | 'target'>,
[],
SlotsType<NuxtLinkSlots<CustomProp>>
>>) & Record<string, any>
🤖 Prompt for AI Agents
In packages/nuxt/src/app/components/nuxt-link.ts around lines 529 to 533, the
intersection with AnchorHTMLAttributes collapses overlapping keys (e.g., href,
rel, target) causing href to be narrowed to string and losing null/union
options; fix by omitting the overlapping keys from the anchor attributes before
merging (use Omit<AnchorHTMLAttributes, keyof NuxtLinkProps<CustomProp>> or
explicitly Omit<AnchorHTMLAttributes, "href" | "rel" | "target">) so the
NuxtLinkProps definitions for href/rel/target are preserved when combined with
anchor attributes.

Choose a reason for hiding this comment

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

@danielroe

In practice, href gets narrowed to string, so passing a route object ... now produces a type error.

This warning seems to be correct - i get type errors on NuxtLink when passing an object as href in v4.1.3

Copy link

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

@danielroe danielroe merged commit 107197b into main Sep 27, 2025
121 of 124 checks passed
@danielroe danielroe deleted the fix/nuxt-link-props branch September 27, 2025 14:11
@github-actions github-actions bot mentioned this pull request Sep 27, 2025
@github-actions github-actions bot mentioned this pull request Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NuxtLink does not accept event listeners as props in explicit component export

2 participants