Vue Component Props上的数组类型破坏了Linter

时间:2018-06-23 00:35:59

标签: typescript vue.js tslint

我正在使用Vue.extend ...使用Array prop创建一个AppProps类。

import Vue from 'vue';
import Component from 'vue-class-component';

const AppProps = Vue.extend({
  props: {
    test1: String,
    test2: Array,
  },
});

然后扩展AppProps以创建我的组件。

@Component({})
export default class ArrayPropsExample extends AppProps {
  get computedMessage() {
    return this.test1 + ' ' + this.test2;
  }
}

这是根据vue-class-component中的打字稿示例得出的。 Vue很高兴,但小子抱怨说在课堂上看不到我的道具类型...

  

19:17类型'ArrayPropsExample'上不存在属性'test1'。       17 |导出默认类ArrayPropsExample扩展AppProps {       18 |得到compactMessage(){

     
    

19 |返回this.test1 +''+ this.test2;            | ^         20 | }         21 | }

  

相关代码在这里(https://github.com/JavascriptMick/vue-d3-poc/blob/master/src/components/ArrayPropsExample.vue

如果我将test2类型设置为String,则linter很高兴,但是使用Array似乎会破坏linter。

1 个答案:

答案 0 :(得分:1)

好,因此我可以通过更改方法来解决这个问题。本质上带来了vue-property-decorator并在我的tsconfig中设置script = false ...

Invoke-Command

我还是更喜欢这种方法。