mobxjs / mobx-vue-lite

Lightweight Vue 3 bindings for MobX based on Composition API.
MIT License
72 stars 3 forks source link

Type error when installing as global plugin #134

Closed hartmannj closed 8 months ago

hartmannj commented 8 months ago

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?

wobsoriano commented 8 months ago

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

hartmannj commented 8 months ago

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.