-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Typescript definitions not working? #673
Comments
I ended up doing the same thing... |
Same issue here. |
Hi I am still getting this error : Console:Argument of type 'typeof "D:/Workshop/nodejs/ef-web-components/node_modules/vue-resource/types/index"' is not assig
Component:import VueResource from 'vue-resource'; package.json{ |
@krishghata Fixed in 1.5.1, you are using 1.5.0, you can manully copy the files in https://github.com/pagekit/vue-resource/tree/develop/types or use my fork by: |
When will this be officially released so we don't need the above tarball link from @NateScarlet ? Would much prefer to do an |
Using 1.5.1, still can't access $http or http in Vue. I have import and use vue-resource in main.ts: according to vue docs , someone have to do something like: declare module 'vue/types/vue' {
// Global properties can be declared
// on the `VueConstructor` interface
interface VueConstructor {
$myGlobal: string
}
} But vue-resource is not doing something like this, which make $http not accessable from global |
As a temporary workaround, I manually add some declaration to projectRoot/node_modules/vue-resource/types/vue.d.ts: /**
* Extends interfaces in Vue.js
*/
import Vue from "vue";
import { HttpHeaders, HttpOptions, HttpResponse, $http, $resource } from "./vue_resource";
declare module "vue/types/options" {
interface ComponentOptions<V extends Vue> {
http?: (HttpOptions & { headers?: HttpHeaders } & { [key: string]: any })
}
}
declare module "vue/types/vue" {
interface Vue {
$http: {
(options: HttpOptions): PromiseLike<HttpResponse>;
get: $http;
post: $http;
put: $http;
patch: $http;
delete: $http;
jsonp: $http;
};
$resource: $resource;
}
interface VueConstructor {
http: {
(options: HttpOptions): PromiseLike<HttpResponse>;
get: $http;
post: $http;
put: $http;
patch: $http;
delete: $http;
jsonp: $http;
};
resource: $resource;
}
} |
I've made a workarond by casting Vue to 'any' like this:
This removed the error message from TS compiler. |
I am still getting this stupid error vue 1.2.13 |
Hey guys!
I'm currently trying to upgrade our project running vue 2.3x to vue 2.5.13 and i can't make it use VueRessource.
My vue imports and use are declared this way
But the TS compilation fails with the following error :
I'm running the latest libraries versions : vue@2.5.13 and vue-resource@1.3.6 (double checked in the node_modules)
If it's of any help, i'm using yarn.
Cheers,
Clément
The text was updated successfully, but these errors were encountered: