Skip to content

fix: watch() typeof check on array is always false #850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 14, 2025

Conversation

hichem-dahi
Copy link
Contributor

@hichem-dahi hichem-dahi commented Apr 13, 2025

πŸ”— Linked issue

resolves #849, resolves #768

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • [x ] 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Destructured the watched values in the callback and applied the typeof check directly on state. Now:

  • If state is an object (non-null), it calls deepSync.
  • If state is a primitive, it assigns proxy.value directly.

The watch callback was checking the typeof the entire array [props.revision, props.state], which always returns "object", causing it to always enter the deepSync branch β€” even when props.state is a primitive (e.g., string, number).

@antfu antfu merged commit a873199 into nuxt:main Apr 14, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix: watch() logic typeof check on array is always false fix: TypeError: 0 is read-only
2 participants