Closed abdullaev closed 6 years ago
Can you show the code ?
It's example with counter from README
Just upgraded to 0.5.0 and I'm also getting this. I think a full working sample application in this repo would be extremely useful.
I'm experiencing the same issues after upgrading to 0.5.0
@Module({ namespaced: true })
export class VacationCalendarVuexModule extends VuexModule {
...
}
it produces the following error
Uncaught TypeError: Class constructor VuexModule cannot be invoked without 'new'
at new VacationCalendarVuexModule (vacation-calendar.ts:78)
at Object.stateFactory (stateFactory.js:4)
at stateFactory (index.js:8)
at eval (index.js:10)
at __decorate (vacation-calendar.ts:40)
at eval (vacation-calendar.ts:137)
at Object../ClientApp/store/modules/vacation-calendar.ts (bootstrap:791)
at __webpack_require__ (bootstrap:724)
at fn (bootstrap:101)
at eval (index.ts:7)
Inspecting the line at vacation-calendar.ts:78 for me shows this
_this = _possibleConstructorReturn(this, _getPrototypeOf(VacationCalendarVuexModule).apply(this, arguments));
specifically the .apply
seems to be failing.
"@babel/core": "^7.0.0-beta.54",
"@babel/plugin-proposal-class-properties": "^7.0.0-beta.54",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0-beta.54",
"@babel/plugin-transform-runtime": "^7.0.0-beta.54",
"@babel/polyfill": "^7.0.0-beta.54",
"typescript": "^3.0.3",
"vue": "^2.5.16",
"vuex": "^3.0.1",
"vuex-class": "^0.3.1",
the same issue,look forward to come out a solution
most likely to work fine with v0.6.0
I think this is a very good example of how to use https://github.com/Armour/vue-typescript-admin-template
This error also occurs when use version 0.6.0
yes, the error occurs at version 0.6.0 as the same
Can you guys show me your webpack/rollup configs ? I feel this is a es6 -> es5 transpilation level issue
v0.7.1 really totally fixes this. I finally figured out what the issue was
v0.8.0 - all ok v0.9.0 - occurs this error (Class constructor VuexModule cannot be invoked without 'new')
You need to transpile this module.
The README tells how to transpile dependencies via babel. I distribute it as ES6. If your target is ES5, you should transpile.
On Tue 30 Oct, 2018, 4:24 AM Nikolay Maksimov, notifications@github.com wrote:
v0.8.0 - all ok v0.9.0 - occurs this error (Class constructor VuexModule cannot be invoked without 'new')
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/championswimmer/vuex-module-decorators/issues/11#issuecomment-434110611, or mute the thread https://github.com/notifications/unsubscribe-auth/ABQ_yuSxL3BAx0mOj9KOpmcjQGAeDTArks5up4cIgaJpZM4WaotK .
I had the same issue, I even tried transpileDependencies: ['vuex-module-decorators']
but it didn't work.
I had to use 0.8.0 version instead (thanks @KleinMaximus!).
are you using Typescript only or Typescript + Babel setup ?
Typescript + Babel (I used vue-cli for the setup).
I have same issue.
My TS transpile option is 'esnext'. and i had 0.9.0 version.
but i set transpileDependencies: ['vuex-module-decorators']
, then it's works.
@ruifigueira In that case
transpileDependencies: ['vuex-module-decorators']
in your vue.config.js should work
I have 0.9.0 installed and I tried adding this to my vue.config.js
module.exports = { transpileDependencies: ['vuex-module-decorators'] }
still get the error and my tsconfig looks like this:
{ "compilerOptions": { "target": "esnext", "module": "esnext", "strict": true, "jsx": "preserve", "importHelpers": true, "moduleResolution": "node", "experimentalDecorators": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "sourceMap": true, "baseUrl": ".", "types": [ "webpack-env", "mocha", "chai", "vuetify" ], "paths": { "@/": [ "src/" ] }, "lib": [ "esnext", "dom", "dom.iterable", "scripthost" ] }, "include": [ "src//*.ts", "src/*/.tsx", "src//*.vue", "tests/*/.ts", "tests/*/.tsx" ], "exclude": [ "node_modules" ] }
And FYI 0.8.0 works, no issues.
transpileDependencies: ['vuex-module-decorators']
works for me
@championswimmer what i have to do if I dont use vue-cli and my tsconfig target is es5?
Depending on your tool you need to make sure your transpiler transpiles this module vuex-module-decorators
too.
If ES5 support is not utterly essential, you can make your entire project target es2015, in which case the library will work as it is.
@KleinMaximus with .90?
@championswimmer this is all I have in my vue.config.js
module.exports = { transpileDependencies: ['vuex-module-decorators'] }
I also meet this problem when updating my code, add transpileDependencies: ['vuex-module-decorators']
fix it.
https://github.com/Armour/vue-typescript-admin-template now is with the latest version of vuex-module-decorators
@aceven24 Did you ever solve this? I just created a new TypeScript project with the latest Vue CLI yesterday, and whether or not I set transpileDependencies
in my vue.config.js
makes no difference.
EDIT: Never mind, it does work. Ended up being a caching issue. Do note that you'll also need babel.config.js
for transpileDependencies
to work.
Everyone please vote here https://github.com/championswimmer/vuex-module-decorators/issues/68
Need your opinions
"Class constructor VuexModule cannot be invoked without 'new'"
The problem exists in 0.5.0 release, with 0.4.3 everything is ok