VueでSSRをしようとしており、ここをtypescriptで書いている時に詰まっています。
entry
1import Vue from 'vue'; 2 3Vue.mixin({ 4 beforeRouteUpdate(to, from, next) { 5 const { asyncData } = this.$options 6 if (asyncData) { 7 asyncData({ 8 store: this.$store, 9 route: to 10 }).then(next).catch(next) 11 } else { 12 next() 13 } 14 } 15})
この時、this.$options
とthis.$store
に対して以下の2つのエラーが出てきてしまい、コンパイルできません。
Property '$options' does not exist on type 'VueConstructor<Vue> | ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<string, any>>'. Property '$store' does not exist on type 'VueConstructor<Vue> | ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<string, any>>'.
TypeScriptの初心者なのですが、このようなデフォルト?の型定義にはないものを使いたい際に、その定義はどのように行えばよいのでしょうか?
よろしくお願いします。
追記
一応、TypeScriptであることを捨てたような対策は見つかりました。
typescript
1(this as any).$options
あなたの回答
tips
プレビュー