nuxt-community / nuxt-property-decorator

Property decorators for Nuxt (base on vue-property-decorator)
https://github.com/kaorun343/vue-property-decorator
MIT License
399 stars 34 forks source link

@ProvideReactive throws "Object(...) is not a function" error #61

Closed kpturner closed 4 years ago

kpturner commented 4 years ago

nuxt-property-decorator version 2.5.0 (uses vue-property-decorator 8.3.0)

const InjectKey = Symbol();
...

@ProvideReactive(InjectKey) foo: any = {};

causes the following error to appear in the browser console

consola.browser.js:1 error TypeError: Object(...) is not a function
    at Module../node_modules/babel-loader/lib/index.js?!./node_modules/ts-loader/index.js?!./node_modules/vue-loader/lib/index.js?!./blah/blah)
    at __webpack_require__ (bootstrap:787)
    at fn (bootstrap:150)
    at Module..blah/blah.vue?vue&type=script&lang=ts& (foo.vue?bdef:1)
    at __webpack_require__ (bootstrap:787)
    at fn (bootstrap:150)
    at Module..blah/blah.vue (foo.vue:1)
    at __webpack_require__ (bootstrap:787)
    at fn (bootstrap:150)
    at Module../node_modules/babel-loader/lib/index.js?!./node_modules/ts-loader/index.js?!./node_modules/vue-loader/lib/index.js?!./blah/blah.vue?vue&type=script&lang=ts& (blah..34da5257.js:2920)
ajshortt commented 4 years ago

Getting the same issue. I think @ProvideReactive hasn't been setup in the nuxt-property-decorator from vue-property-decorator. I'm going to have a look and if fixable, will put a PR in

ajshortt commented 4 years ago

@kpturner This has been resolved in PR by @miii which changes src/nuxt-property-decorator.ts but this hasn't been compiled and released via NPM. I have put a PR in with the compiled lib file and have requested that a release be made to NPM.

If you really need this feature now, you can always add my forked version to your package.json which has the fix. BUT if you choose to do so, I strongly recommend watching the nuxt community repo for new releases and switch back upon new release 👍

npm install https://git@github.com/ajshortt/nuxt-property-decorator.git
husayt commented 4 years ago

@ajshortt thanks for merge request. The new release was due anyway, so I'll get this in before releasing.

ajshortt commented 4 years ago

Cool thanks @husayt. I've put a PR in with the compilation #64

kpturner commented 4 years ago

Ok thanks - I’ll wait