fix(types): widen ClassValue to accept fallthrough attrs values#14492
fix(types): widen ClassValue to accept fallthrough attrs values#14492edison1105 wants to merge 1 commit intomainfrom
Conversation
📝 WalkthroughWalkthroughFixes a regression where assigning Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested labels
Poem
🚥 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)
Comment |
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
|
/ecosystem-ci run |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages-private/dts-test/tsx.test-d.tsx (1)
64-67: Add a negative assertion to prevent over-wideningclasstyping.Please pair this with a
//@ts-expect-error`` case (e.g.class={123}) so the suite also enforces that invalid class values remain rejected.Suggested dts-test addition
// allow class passthrough from attrs const attrs = useAttrs() expectType<JSX.Element>(<div class={attrs.class} />) + +// `@ts-expect-error` invalid class value should still be rejected +;<div class={123} />🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages-private/dts-test/tsx.test-d.tsx` around lines 64 - 67, Add a negative type assertion to the existing test that verifies class passthrough from useAttrs does not over-widen the type: after the positive expectType<JSX.Element>(<div class={attrs.class} />) add a failing case annotated with // `@ts-expect-error` that tries an invalid class value (for example class={123}) to ensure the compiler still rejects non-string/non-string[] class values; update the tsx.test-d.tsx around the useAttrs/attrs assertions so both the valid passthrough and the explicit invalid-case are present.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages-private/dts-test/tsx.test-d.tsx`:
- Around line 64-67: Add a negative type assertion to the existing test that
verifies class passthrough from useAttrs does not over-widen the type: after the
positive expectType<JSX.Element>(<div class={attrs.class} />) add a failing case
annotated with // `@ts-expect-error` that tries an invalid class value (for
example class={123}) to ensure the compiler still rejects
non-string/non-string[] class values; update the tsx.test-d.tsx around the
useAttrs/attrs assertions so both the valid passthrough and the explicit
invalid-case are present.
|
📝 Ran ecosystem CI: Open
|
close #14489
Summary by CodeRabbit
Tests
Refactor