fix(reactivity): allow async watchEffect callbacks#14656
fix(reactivity): allow async watchEffect callbacks#14656Misrilal-Sah wants to merge 1 commit intovuejs:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR widens the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related issues
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Pull request overview
Updates Vue reactivity typings so watchEffect callbacks can be async (i.e., return a Promise<void>), matching documented/common usage and avoiding TS/ESLint “void-return expected” friction.
Changes:
- Broaden
WatchEffectreturn type fromvoidtovoid | Promise<void>. - Add a DTS regression test ensuring
asyncwatchEffectcallbacks type-check.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/reactivity/src/watch.ts | Expands WatchEffect type to allow Promise<void> return. |
| packages-private/dts-test/watch.test-d.ts | Adds DTS coverage for async watchEffect usage (#14249). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
duplicate of #14251 |
Issue link
[https://github.com//issues/14249
Description
This PR updates WatchEffect typing to allow async callbacks by accepting Promise in addition to void.
Why
watchEffect is documented and commonly used with async functions, but the previous type signature rejected this pattern and caused lint/type friction.
Changes
Updated WatchEffect type to support async callbacks.
Added dts regression coverage to ensure async watchEffect callbacks are accepted.
Summary by CodeRabbit
New Features
watchEffectnow supports async callbacks in addition to synchronous ones.Tests
watchEffectcallbacks with cleanup support.