Skip to content

3.5.29 regression: type error when assigning $attrs.class to :classΒ #14489

@IGx89

Description

@IGx89

Vue version

3.5.29

Link to minimal reproduction

https://stackblitz.com/edit/vue3-vite-typescript-starter-lef7lqpi?file=package.json

Steps to reproduce

The following will produce a type error in both VS Code and vue-tsc in 3.5.29 (but not 3.5.28 and earlier):

<template>
	<div :class="$attrs.class" />
</template>

The Stackblitz repro will reproduce the type error too if you run npm run build.

What is expected?

No type error

What is actually happening?

Type error:

error TS2345: Argument of type '{ class: unknown; }' is not assignable to parameter of type 'HTMLAttributes & ReservedProps & Record<string, unknown>'.
  Type '{ class: unknown; }' is not assignable to type 'HTMLAttributes'.
    Types of property 'class' are incompatible.
      Type 'unknown' is not assignable to type 'ClassValue'.

<div :class="$attrs.class">

System Info

System:
    OS: Windows 11 10.0.26200
    CPU: (16) x64 AMD Ryzen 7 PRO 6850U with Radeon Graphics
    Memory: 3.78 GB / 30.77 GB
  Binaries:
    Node: 24.13.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 4.0.2 - C:\Program Files\nodejs\yarn.CMD
    npm: 11.6.2 - C:\Program Files\nodejs\npm.CMD
    pnpm: 10.30.1 - C:\Program Files\nodejs\pnpm.CMD
  Browsers:
    Edge: Chromium (143.0.3650.80)
    Internet Explorer: 11.0.26100.7309

Any additional comments?

This is a regression caused by #14441 changing the type of HTMLAttributes.class from any to ClassValue | undefined, while the type of $attrs is just Record<string, unknown>

Metadata

Metadata

Assignees

No one assigned

    Labels

    πŸ”¨ p3-minor-bugPriority 3: this fixes a bug, but is an edge case that only affects very specific usage.regressionscope: types

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions