Skip to content

Comments

refactor(useClipboard): improve type safety#5075

Closed
broBinChen wants to merge 1 commit intovueuse:mainfrom
broBinChen:refactor/improve-type-assertions
Closed

refactor(useClipboard): improve type safety#5075
broBinChen wants to merge 1 commit intovueuse:mainfrom
broBinChen:refactor/improve-type-assertions

Conversation

@broBinChen
Copy link
Contributor

…ype assertions

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.
⚠️ Slowing down new functions

Warning: Slowing down new functions

As the VueUse audience continues to grow, we have been inundated with an overwhelming number of feature requests and pull requests. As a result, maintaining the project has become increasingly challenging and has stretched our capacity to its limits. As such, in the near future, we may need to slow down our acceptance of new features and prioritize the stability and quality of existing functions. Please note that new features for VueUse may not be accepted at this time. If you have any new ideas, we suggest that you first incorporate them into your own codebase, iterate on them to suit your needs, and assess their generalizability. If you strongly believe that your ideas are beneficial to the community, you may submit a pull request along with your use cases, and we would be happy to review and discuss them. Thank you for your understanding.


Description

Fix incorrect type assertions in useClipboard by wrapping values with computed() instead of using unsafe type casts.

Additional context

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Sep 30, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 30, 2025

Open in StackBlitz

@vueuse/components

npm i https://pkg.pr.new/@vueuse/components@5075

@vueuse/core

npm i https://pkg.pr.new/@vueuse/core@5075

@vueuse/electron

npm i https://pkg.pr.new/@vueuse/electron@5075

@vueuse/firebase

npm i https://pkg.pr.new/@vueuse/firebase@5075

@vueuse/integrations

npm i https://pkg.pr.new/@vueuse/integrations@5075

@vueuse/math

npm i https://pkg.pr.new/@vueuse/math@5075

@vueuse/metadata

npm i https://pkg.pr.new/@vueuse/metadata@5075

@vueuse/nuxt

npm i https://pkg.pr.new/@vueuse/nuxt@5075

@vueuse/router

npm i https://pkg.pr.new/@vueuse/router@5075

@vueuse/rxjs

npm i https://pkg.pr.new/@vueuse/rxjs@5075

@vueuse/shared

npm i https://pkg.pr.new/@vueuse/shared@5075

commit: 9ff3bdd

@codecov
Copy link

codecov bot commented Sep 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.24%. Comparing base (01534ec) to head (9ff3bdd).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5075   +/-   ##
=======================================
  Coverage   66.24%   66.24%           
=======================================
  Files         365      365           
  Lines       14565    14565           
  Branches     2399     2401    +2     
=======================================
  Hits         9648     9648           
  Misses       4906     4906           
  Partials       11       11           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@9romise 9romise left a comment

Choose a reason for hiding this comment

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

Based on the git history, the original coercion to ComputedRef was intended to enforce read-only. Therefore, I believe it would be more appropriate to use readonly instead of converting it to a computed.

See: 9438bc2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants