vueuse: Argument of type 'Ref' is not assignable to parameter of type 'MaybeElementRef'.
Describe the bug
What is the cause of this problem? How to solve it?
Argument of type 'Ref<null>' is not assignable to parameter of type 'MaybeElementRef<MaybeElement>'.
Property '[RefSymbol]' is missing in type 'Ref<null>' but required in type 'Ref<MaybeElement>'.ts(2345)
reactivity.d.ts(458, 5): '[RefSymbol]' is declared here.
code
import { onClickOutside } from '@vueuse/core';
const target = ref(null);
onClickOutside(target, () => {
isShowCandidate.value = false;
});
return () => (
<div ref={target}></div>
);
package.json
"dependencies": {
"@vueuse/components": "^10.2.1",
"@vueuse/core": "^9.13.0",
"vue": "3.2.47",
},
Ref
Solved without doing anything? https://github.com/vueuse/vueuse/issues/405
Reproduction
System Info
System:
OS: macOS 13.4.1
CPU: (8) arm64 Apple M1
Memory: 106.36 MB / 8.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 16.20.0 - ~/.nvm/versions/node/v16.20.0/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v16.20.0/bin/yarn
npm: 8.19.4 - ~/.nvm/versions/node/v16.20.0/bin/npm
Browsers:
Chrome: 114.0.5735.198
Firefox: 114.0.1
Safari: 16.5.2
npmPackages:
@vueuse/core: ^9.13.0 => 9.13.0
Used Package Manager
pnpm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a VueUse issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion.
- The provided reproduction is a minimal reproducible example of the bug.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 10
- Comments: 22 (9 by maintainers)
Commits related to this issue
- CHORE: Packages updated Resolves issue https://github.com/vueuse/vueuse/issues/3240 — committed to kier-mc/portfolio-2024 by kier-mc 3 years ago
I think it should be necessary to clarify this question, because I am not the only one who has questions.
I’m seeing this issue too when trying to upgrade my library to vue 3.3.
@rich1e How?
I don’t count this much has a solution.
Does it work for you?
This continues to be an issue:
vue: 3.4.21nuxt: 3.10.1@vueuse/core: 10.9.0Some errors I’m seeing:
This is an issue I’ve been facing when I’m creating modules with Nuxt 3.8.*. I initially thought it was a tsserver issue, but it happens to be a problem with the types for VueUse, because replacing the type with Vue’s native
Refworks.For what it’s worth, I encountered this issue with
@vueuse/core: 12.5.0andvue: 3.5.12. Once I upgraded tovue: 3.5.13the error went away.I can verify the same in a fresh Vue project I created with
npm create vue@latest.It looks like it has already been fixed.
Exact same thing as @dev-abota with :
vue: 3.4.15@vueuse/core: 10.9.0Was working with:
vue: 3.2.47@vueuse/core: 10.7.0