Problem installing Pinia on Vue 2.7 with Typescript #2008
Replies: 2 comments 4 replies
-
Out of curiosity, is there other people here that use the same stack that I have? I ask the question because I wonder if Pinia works with Typescript only in Vue 3. In order to fix this error, I had to redeclare locally the pinia option:
The one in the pinia.d.ts file isn't found by the ts linter even if I declare types: ["pinia"] in the tsconfig. |
Beta Was this translation helpful? Give feedback.
-
Did you get any fix working ? I'm having the exact same problem on typescript + vue 2.7 + pinia |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
I'm trying to install Pinia on Vue.js 2.7/Typescript, but I get an error when I add the required code to add to main.ts in order to install the plugin and inject the created pinia at the root of the app.
What I added to the main.ts:
`import { createPinia, PiniaVuePlugin } from "pinia"
Vue.use(PiniaVuePlugin)
const pinia = createPinia()
export default new Vue({
i18n,
vuetify,
router,
store,
pinia,
render: (h) => h(App)
}).$mount("#app")`
And I get the following compilation error:
`src/main.ts:58:3
TS2769: No overload matches this call.
Overload 1 of 3, '(options?: ThisTypedComponentOptionsWithArrayProps<Vue<Record<string, any>, Record<string, any>, never, never, (event: string, ...args: any[]) => Vue<Record<string, any>, Record<string, any>, never, never, ...>>, ... 6 more ..., ComponentOptionsMixin> | undefined): CombinedVueInstance<...>', gave the following error.
Overload 2 of 3, '(options?: ThisTypedComponentOptionsWithRecordProps<Vue<Record<string, any>, Record<string, any>, never, never, (event: string, ...args: any[]) => Vue<Record<string, any>, Record<string, any>, never, never, ...>>, ... 6 more ..., ComponentOptionsMixin> | undefined): CombinedVueInstance<...>', gave the following error.
Argument of type '{ i18n: VueI18n; vuetify: Vuetify; router: VueRouter; store: Store; pinia: Pinia; render: (h: CreateElement) => VNode; }' is not assignable to parameter of type 'ThisTypedComponentOptionsWithRecordProps<Vue<Record<string, any>, Record<string, any>, never, never, (event: string, ...args: any[]) => Vue<Record<string, any>, Record<string, any>, never, never, ...>>, ... 6 more ..., ComponentOptionsMixin>'.
Overload 3 of 3, '(options?: ComponentOptions<Vue<Record<string, any>, Record<string, any>, never, never, (event: string, ...args: any[]) => Vue<Record<string, any>, Record<string, any>, never, never, ...>>, ... 7 more ..., ComponentOptionsMixin> | undefined): CombinedVueInstance<...>', gave the following error.
Does someone has an idea about what is missing in order to fix this? It seems that some types are missing, but I thought the plugin adds the the required types? Thanks!
Beta Was this translation helpful? Give feedback.
All reactions