I have been tackling a Typescript issue in a Vue project that relies on vue-resource. Despite the project functioning properly, I am encountering a typescript compiler error.
https://i.sstatic.net/RFT8B.png https://i.sstatic.net/A2MZm.png
I have managed to utilize the module using this.$http
in my components.
After exploring this, this, and this, I have not found a solution. Is there a workaround for this problem? Or a method to set global options in Vue-Resource with Typescript? Alternatively, is there a way to bypass the error completely?
[Edit] Solution (also provided as my response):
One possible workaround from @Styx's suggestion (modifying the Github solution is quite hacky, as I prefer not to manually edit vue-resource/types/vue.d.ts
, but including it here nonetheless.
Using generics and typecasting Vue to any, for instance <any>Vue.http
. However, this approach may trigger a tslint warning, so I addressed this by utilizing (Vue as any)
and then accessing (Vue as any).http