mobxjs/mobx-vue-lite

Type error when installing as global plugin

Closed this issue · 2 comments

I am not able to register the Observer globally because of below type error. I am using mobx-vue-lite 0.4.1 and vue 3.4.15.

Following code

// main.js
import { createApp } from 'vue'
import Observer from 'mobx-vue-lite'

const app = createApp(App)
app.use(Observer)

throws a type error:

Argument of type

DefineComponent<{}, {}, { key: number; dispose: () => void; }, {}, { forceUpdate(): void; }, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, VNodeProps & ... 1 more ... & ComponentCustomProps, Readonly<...>, {}, {}>

is not assignable to parameter of type Plugin<[]>

Type

DefineComponent<{}, {}, { key: number; dispose: () => void; }, {}, { forceUpdate(): void; }, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, VNodeProps & ... 1 more ... & ComponentCustomProps, Readonly<...>, {}, {}>

is not assignable to type FunctionPlugin<[]>

Any idea what the problem is?

Still investigating but both the default and named export works on my end (no TS errors) in a fresh Vite project:

Screenshot 2024-02-03 at 4 39 13 PM

Thanks for the quick answer. Just realised Webstorm was actually auto importing as following

import { Observer } from 'mobx-vue-lite'

which throws this error. Using Observer as default import works.