microsoft / TypeScript-Vue-Starter

A starter template for TypeScript and Vue with a detailed README describing how to use the two together.
MIT License
4.45k stars 592 forks source link

Does not build, got errors TS1238 and TS2509 #39

Closed sfermigier closed 6 years ago

sfermigier commented 6 years ago
➜  TypeScript-Vue-Starter git:(master) ✗ yarn
yarn install v1.5.1
[1/4] 🔍  Resolving packages...
success Already up-to-date.
✨  Done in 0.39s.
➜  TypeScript-Vue-Starter git:(master) ✗ npm run build

> typescript-vue-starter@1.0.0 build /Users/fermigier/git/vue/TypeScript-Vue-Starter
> webpack

ts-loader: Using typescript@2.3.2 and /Users/fermigier/git/vue/TypeScript-Vue-Starter/tsconfig.json
Hash: e7974bc5938b571dfaab
Version: webpack 2.5.0
Time: 2370ms
   Asset     Size  Chunks                    Chunk Names
build.js  1.08 MB       0  [emitted]  [big]  main
   [0] ./~/vue/dist/vue.esm.js 292 kB {0} [built]
   [1] ./~/process/browser.js 5.42 kB {0} [built]
   [2] (webpack)/buildin/global.js 509 bytes {0} [built]
   [3] ./~/css-loader/lib/css-base.js 2.26 kB {0} [built]
   [4] ./~/vue-loader/lib/component-normalizer.js 2.55 kB {0} [built]
   [5] ./~/vue-style-loader/lib/addStylesClient.js 6.05 kB {0} [built]
  [10] ./~/reflect-metadata/Reflect.js 52.3 kB {0} [built]
  [11] ./~/setimmediate/setImmediate.js 6.47 kB {0} [built]
  [12] ./~/timers-browserify/main.js 1.36 kB {0} [built]
  [15] ./src/index.ts 666 bytes {0} [built]
  [16] ./~/vue-class-component/dist/vue-class-component.common.js 8.05 kB {0} [built]
  [19] ./~/vue-property-decorator/lib/vue-property-decorator.umd.js 4.85 kB {0} [built]
  [22] ./~/vue-style-loader/lib/listToStyles.js 639 bytes {0} [built]
    + 10 hidden modules

ERROR in /Users/fermigier/git/vue/TypeScript-Vue-Starter/src/components/HelloDecorator.vue.ts
(14,1): error TS1238: Unable to resolve signature of class decorator when called as an expression.
  Type '<VC extends VueClass<Vue>>(target: VC) => VC' is not assignable to type 'typeof HelloDecorator'.
    Property 'extend' is missing in type '<VC extends VueClass<Vue>>(target: VC) => VC'.

ERROR in /Users/fermigier/git/vue/TypeScript-Vue-Starter/src/components/HelloDecorator.vue.ts
(15,45): error TS2509: Base constructor return type 'CombinedVueInstance<Vue, Data, Methods, Computed, Record<PropNames, any>>' is not a class or interface type.
vindarel commented 6 years ago

Hello, I have two different issues (!):

$ npm run build
ERROR in /home/vince/bacasable/TypeScript-Vue-Starter/src/components/HelloDecorator.vue.ts
(16,13): error TS2564: Property 'name' has no initializer and is not definitely assigned in the constructor.

ERROR in /home/vince/bacasable/TypeScript-Vue-Starter/src/components/HelloDecorator.vue.ts
(17,13): error TS2564: Property 'initialEnthusiasm' has no initializer and is not definitely assigned in the constructor.

Debian, node v9.3, npm 5.5.

Regards

ThePlastic commented 6 years ago

@vindarel I faced the same error updating typescript to 2.7.2 in my case, to solve it was enough to add this line

"strictPropertyInitialization": false,

to the CompilerOptions property into the tsconfig.json file

vindarel commented 6 years ago

that made it ! Thanks.

DanielRosenwasser commented 6 years ago

Duplicate of #36.

zhangenming commented 5 years ago

"strictPropertyInitialization": false, didn't work with me node v10.14.1 tsc v3.2.1 still has this problem @DanielRosenwasser