Axel Stone
Axel Stone

Reputation: 1580

Cannot use property decorator @Prop in vue

I have a component in Vue 2:

import Vue from 'vue';
import Component from 'vue-class-component';
import Prop from 'vue-property-decorator';

@Component({
  template: require('./template.html'),
})

export class SuklTableApprComponent extends Vue {

  @Prop() 
  type: any;

  @Prop()
  data: any;

  mounted() {}

}

I am doing it as stated in documentation, but typescript won't let me use that @Prop decorator. It throws an error:

TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'typeof "/home/tomasturan/programming/sukl/reg-dis-forms-v2/node_modules/vue-property-decorator/li...' has no compatible call signatures.

Why is that? I have a simmilar project where everything seems to be configured the same and there it works. Why is it throwing this error?

Upvotes: 0

Views: 3346

Answers (1)

Titian Cernicova-Dragomir
Titian Cernicova-Dragomir

Reputation: 249646

I think the problem is with your import statement.

import Vue from 'vue';
import Component from 'vue-class-component';
import { Prop } from 'vue-property-decorator'; // no default import, used { Prop } to import the decorator

@Component({
  template: require('./template.html'),
})
export class SuklTableApprComponent extends Vue {

  @Prop()
  type: any;
  @Prop()
  data: any;
  mounted() { }

}

Upvotes: 5

Related Questions