vueuse: Typescript Error when using useStorage in Pinia Store - pnpm
Describe the bug
When using useStorage in a Pinia store declaration typescript throws the following error:
The inferred type of 'useCounterStore' cannot be named without a reference to '.pnpm/@vueuse+shared@9.8.0_vue@3.2.47/node_modules/@vueuse/shared'. This is likely not portable. A type annotation is necessary.

The Error disappears when importing RemovableRef seperately but then there would be an unused import. I also found that the error disappears when setting "preserveSymlinks: true" in the tsconfig but then typescript complains about vue not having exports named Ref, createApp etc.
I could reproduce it by setting up a new project with create-vue and just installing vueuse/core, therefore I believe it actually is a bug, but please correct me if some setup with pnpm/typescript etc. is wrong here.
Reproduction
https://github.com/robinpilz/vueuse-pinia-minimal-repro
System Info
System:
OS: Linux 5.15 Ubuntu 20.04.5 LTS (Focal Fossa)
CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
Memory: 4.66 GB / 15.47 GB
Container: Yes
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 18.1.0 - ~/.nvm/versions/node/v18.1.0/bin/node
Yarn: 1.22.18 - ~/.yarn/bin/yarn
npm: 8.18.0 - ~/.nvm/versions/node/v18.1.0/bin/npm
Browsers:
Firefox: 110.0
npmPackages:
@vueuse/core: 9.8.0 => 9.8.0
vue: ^3.2.47 => 3.2.47
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 4 years ago
- Comments: 15
I found a quickfix, which is to import
type RemovableRef. You don’t even have to use it anywhere, just importing it will fix the TS error.Example below taken from your repro, but turned into Setup store notation, haven’t tested Option syntax).
Before:
After:
After (variant)
To make sure other devs don’t remove the import, you could use it like this:
Note that I’d use
satisfies, notas, since we preferably don’t do any type casting, we just want to validate that it’s the given type.Small correction to the above workaround:
type RemovableRefis exported by@vueuse/core, notpinia👍Shouldn’t this issues be re-opened ? The hot fix seems to work, but not sure this is the intended behavior