vue-class-component: example error with typescript 2.6.1

$ npm install && npm run example
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

> vue-class-component@6.0.0 example D:\Test\vue-class-component
> npm run build && webpack --config example/webpack.config.js


> vue-class-component@6.0.0 build D:\Test\vue-class-component
> npm run build:ts && npm run build:main


> vue-class-component@6.0.0 build:ts D:\Test\vue-class-component
> tsc -p .

src/component.ts(38,16): error TS2532: Object is possibly 'undefined'.
src/component.ts(40,58): error TS2532: Object is possibly 'undefined'.
src/component.ts(41,16): error TS2532: Object is possibly 'undefined'.
src/component.ts(41,34): error TS2532: Object is possibly 'undefined'.
src/component.ts(44,14): error TS2532: Object is possibly 'undefined'.
src/component.ts(45,14): error TS2532: Object is possibly 'undefined'.

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build:ts"
npm ERR! node v6.10.1
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! vue-class-component@6.0.0 build:ts: `tsc -p .`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the vue-class-component@6.0.0 build:ts script 'tsc -p .'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the vue-class-component package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     tsc -p .
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs vue-class-component
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls vue-class-component
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     D:\Test\vue-class-component\npm-debug.log

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
npm ERR! node v6.10.1
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! vue-class-component@6.0.0 build: `npm run build:ts && npm run build:main`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vue-class-component@6.0.0 build script 'npm run build:ts && npm run build:main'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the vue-class-component package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run build:ts && npm run build:main
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs vue-class-component
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls vue-class-component
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     D:\Test\vue-class-component\npm-debug.log

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "example"
npm ERR! node v6.10.1
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! vue-class-component@6.0.0 example: `npm run build && webpack --config example/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vue-class-component@6.0.0 example script 'npm run build && webpack --config example/webpack.config.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the vue-class-component package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run build && webpack --config example/webpack.config.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs vue-class-component
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls vue-class-component
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     D:\Test\vue-class-component\npm-debug.log

package info:

$ npm ls --depth 0
vue-class-component@6.0.0 D:\Test\vue-class-component
+-- @types/chai@4.0.4
+-- @types/mocha@2.2.44
+-- babel-core@6.26.0
+-- babel-loader@7.1.2
+-- babel-plugin-transform-class-properties@6.24.1
+-- babel-plugin-transform-decorators-legacy@1.3.4
+-- babel-preset-es2015@6.24.1
+-- chai@4.1.2
+-- css-loader@0.28.7
+-- mocha@4.0.1
+-- rimraf@2.6.2
+-- rollup@0.50.0
+-- rollup-plugin-replace@2.0.0
+-- testdouble@3.2.6
+-- ts-loader@2.3.7
+-- typescript@2.6.1
+-- uglify-js@3.1.6
+-- vue@2.5.2
+-- vue-loader@13.3.0
+-- vue-template-compiler@2.5.2
`-- webpack@3.8.1

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 22 (8 by maintainers)

Most upvoted comments

Hi all, just encountered this issue (or something similar) and it was blocking me majorly.

You can downgrade to 2.5, or add “strictFunctionTypes”: false temporarily to get across this hurdle.

Not sure why this was closed, because this was a hard one to figure out. Hope this helps any others (and thanks @HerringtonDarkholme for the key piece of information I needed 👍 )

Where can I find information which version of vue, typescript, vue-loader work together. It’s really a nightmare.

@keenwon, there is new feature in typescript 2.6 // @ts-ignore I just mute it and it work.

This seems only to happen if we compile it with ts-loader. tsc does not provide such errors. I have no idea what is the root cause.

@HerringtonDarkholme Do you have any idea to fix this?

I’m not sure if I can do this, if not please delete my post

@PSausM I was very confused too so I decide to create an article how to fix every issue I got https://webdevelop.pro/vuejs-with-typescript.html

if you updated Vue and still have same issue - make sure you did not forget to update vue-loader, vue-template-compiler and etc

@darylteo Vue2.5.3 has released. Try it!