Skip to content

types(jsx): flexible class attribute declarations - #14441

Merged
edison1105 merged 3 commits into
vuejs:mainfrom
ZacharyBear:ts-class
Feb 24, 2026
Merged

edison1105 merged 3 commits into
vuejs:mainfrom
ZacharyBear:ts-class

Conversation

@ZacharyBear

@ZacharyBear ZacharyBear commented Feb 10, 2026 •

Copy link
Copy Markdown
Contributor

close: vuejs/rfcs#820

Summary by CodeRabbit

  • New Features
    • Introduced a new public ClassValue type to represent flexible class attribute values (booleans, strings, objects, arrays, nested structures), enabling richer and more consistent class specifications.
    • Updated HTML and SVG class attribute typings to use ClassValue, improving type safety and predictability when specifying classes across components.

@coderabbitai

coderabbitai Bot commented Feb 10, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds and exports a new ClassValue type and updates JSX typings so HTMLAttributes.class and SVGAttributes.class use ClassValue | undefined instead of any, modifying the public API in packages/runtime-dom/src/jsx.ts.

Changes

Cohort / File(s) Summary
JSX typings
packages/runtime-dom/src/jsx.ts
Add exported ClassValue type (boolean, string, object records, nested arrays, null/undefined). Replace any with `ClassValue

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • KazariEX

Poem

🐰
I hop through types with nimble feet,
ClassValue makes the typings neat,
Strings and arrays and objects play,
No more any to hide away,
A carrot for clear code today 🥕

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly references the main change: making the class attribute declarations more flexible by introducing proper typing for the class attribute in JSX.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/runtime-dom/src/jsx.ts (1)

928-928: ⚠️ Potential issue | 🟡 Minor

SVGAttributes.class is still typed as any — should use ClassValue too.

SVGAttributes doesn't extend HTMLAttributes, so its class property wasn't updated by this change. It should be updated for consistency.

Proposed fix
-  class?: any
+  class?: ClassValue | undefined

@github-actions

Copy link
Copy Markdown

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 104 kB 39.3 kB 35.4 kB
vue.global.prod.js 162 kB 59.3 kB 52.7 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 47.8 kB 18.6 kB 17.1 kB
createApp 56 kB 21.7 kB 19.8 kB
createSSRApp 60.2 kB 23.4 kB 21.4 kB
defineCustomElement 61.6 kB 23.4 kB 21.4 kB
overall 70.4 kB 27 kB 24.6 kB

@edison1105 edison1105 changed the title feat(runtime-dom): TS description for class attribute types(jsx): flexible class attribute declarations Feb 10, 2026
@pkg-pr-new

pkg-pr-new Bot commented Feb 10, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@14441
npm i https://pkg.pr.new/@vue/compiler-core@14441
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@14441
npm i https://pkg.pr.new/@vue/compiler-dom@14441
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@14441
npm i https://pkg.pr.new/@vue/compiler-sfc@14441
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@14441
npm i https://pkg.pr.new/@vue/compiler-ssr@14441
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@14441
npm i https://pkg.pr.new/@vue/reactivity@14441
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@14441
npm i https://pkg.pr.new/@vue/runtime-core@14441
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@14441
npm i https://pkg.pr.new/@vue/runtime-dom@14441
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@14441
npm i https://pkg.pr.new/@vue/server-renderer@14441
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@14441
npm i https://pkg.pr.new/@vue/shared@14441
yarn add https://pkg.pr.new/@vue/[email protected]

vue

pnpm add https://pkg.pr.new/vue@14441
npm i https://pkg.pr.new/vue@14441
yarn add https://pkg.pr.new/[email protected]

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@14441
npm i https://pkg.pr.new/@vue/compat@14441
yarn add https://pkg.pr.new/@vue/[email protected]

commit: db6dd46

@edison1105

Copy link
Copy Markdown
Member

Thanks for the PR.
Could you please fix the failing dts tests?

@ZacharyBear ZacharyBear left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, this LGTM

Comment thread packages/runtime-dom/src/jsx.ts Resolved

@jacekkarczmarczyk jacekkarczmarczyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

@edison1105

Copy link
Copy Markdown
Member

@ZacharyBear

Copy link
Copy Markdown
Contributor Author

It breaks vuetify. see https://github.com/vuejs/ecosystem-ci/actions/runs/21937604983/job/63355159194

I see, this is because vuetify(and other frameworks depends on vue) passed an unknown type object into class attribute.

I think vuetify needs to use a specific type to suit ClassValue type.

And considering, this type-adding will breaks other frameworks.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@packages/runtime-dom/src/jsx.ts`:
- Line 290: The prop type for JSX "class" was tightened to ClassValue |
undefined which rejects unknown-typed values; revert the prop to accept unknown
(e.g., change the declaration from "class?: ClassValue | undefined" to "class?:
unknown") and ensure normalizeClass still accepts unknown (leave normalizeClass
signature as-is if it already accepts unknown) so callers with unknown-typed
class values (like vuetify) compile; alternatively define and use a thin alias
(e.g., ExportedAcceptClass = ClassValue | unknown) and use that in the JSX prop
to preserve typing intent while allowing unknown via an escape hatch.

Comment thread packages/runtime-dom/src/jsx.ts Resolved
@ZacharyBear

ZacharyBear commented Feb 19, 2026 •

Copy link
Copy Markdown
Contributor Author

It breaks vuetify. see https://github.com/vuejs/ecosystem-ci/actions/runs/21937604983/job/63355159194

As the type problem has been fixed. This ecosystem-checking should be rerun @edison1105

@edison1105

Copy link
Copy Markdown
Member

/ecosystem-ci run

@vuejs vuejs deleted a comment from edison1105 Feb 24, 2026
@vuejs vuejs deleted a comment from ZacharyBear Feb 24, 2026
@vue-bot

vue-bot commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

📝 Ran ecosystem CI: Open

suite result latest scheduled
language-tools ✅ success ✅ success
primevue ✅ success ✅ success
quasar ✅ success ✅ success
vite-plugin-vue ✅ success ✅ success
nuxt ✅ success ✅ success
router ❌ failure ❌ failure
vitepress ✅ success ✅ success
pinia ✅ success ✅ success
vue-i18n ✅ success ✅ success
vue-simple-compiler ✅ success ✅ success
vueuse ✅ success ✅ success
vant ✅ success ✅ success
test-utils ✅ success ✅ success
radix-vue ✅ success ✅ success
vuetify ✅ success ✅ success
vue-macros ✅ success ✅ success

@edison1105 edison1105 added ready to merge The PR is ready to be merged. labels Feb 24, 2026
@edison1105
edison1105 merged commit 521157d into vuejs:main Feb 24, 2026
11 checks passed
@ZacharyBear
ZacharyBear deleted the ts-class branch February 24, 2026 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready to merge The PR is ready to be merged. scope: types

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants