Typescript error when defining global options
Closed this issue · 4 comments
Agusdeluca96 commented
Describe the bug
When trying to set global configuration options via piniaPluginPersistedstate
, the next typescript error get shown:
Reproduction
https://stackblitz.com/edit/pinia-plugin-persistedstate-ts-error-global-options
System Info
System:
OS: macOS 14.2.1
CPU: (11) arm64 Apple M3 Pro
Memory: 64.17 MB / 18.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 19.8.1 - ~/.nvm/versions/node/v19.8.1/bin/node
npm: 9.5.1 - ~/.nvm/versions/node/v19.8.1/bin/npm
pnpm: 8.14.1 - /opt/homebrew/bin/pnpm
Browsers:
Brave Browser: 125.1.66.113
Safari: 17.2.1
Used Package Manager
pnpm
Validations
- Follow our Code of Conduct
- Read the Contributing Guide.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- The provided reproduction is a minimal reproducible of the bug.
prazdevs commented
Please provide a proper reproduction (repo/stackblitz) so I can investigate
Agusdeluca96 commented
Here is a stackblitz with reproduction (also editing original message to add it): https://stackblitz.com/edit/pinia-plugin-persistedstate-ts-error-global-options
prazdevs commented
If you want to pass global options, you must use the plugin factory as such
import { createApp } from 'vue';
import { createPinia } from 'pinia';
import { createPersistedState } from 'pinia-plugin-persistedstate';
import './style.css';
import App from './App.vue';
const app = createApp(App);
const pinia = createPinia();
pinia.use(
createPersistedState({
key: (id) => `__skeleton__${id}`,
})
);
app.use(pinia);
app.mount('#app');
Agusdeluca96 commented
My bad, it was pretty clear on de doc! Thank you Sacha!