1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

vueをtypescriptで使っていてCombinedVueInstanceのエラーが出た時の解決方法

Posted at

↓こんなエラーが出た時の対応策
image.png

package.jsonは以下の通り

  "devDependencies": {
    "@types/dateformat": "^3.0.0",
    "@vue/cli-plugin-typescript": "^3.9.0",
    "@vue/cli-service": "^3.9.2",
    "node-sass": "^4.12.0",
    "sass-loader": "^7.1.0",
    "stats-webpack-plugin": "^0.7.0",
    "typescript": "^3.5.3",
    "vue": "^2.6.10",
    "vue-template-compiler": "^2.6.10",
    "webpack-bundle-analyzer": "^3.3.2"
  }

解決策は、functionに戻り値の型を書く。anyでも良い。

before

  computed: {
    listUlClass: function (){
      return "";
    },
    listLIClass: function () {
      return {};
    },
}

after

  computed: {
    listUlClass: function ():string{
      return "";
    },
    listLIClass: function () :any{
      return {};
    },
}

アロー関数式でない普通のfunctionで戻り値の型を書く発想が無かった・・・。vue3では全部アローで書けるといいな

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?