mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 15:57:13 +00:00
vue-resource: Provides its own types (#39567)
This commit is contained in:
committed by
Jesse Trinity
parent
2494b17f46
commit
7280abd998
@@ -4398,6 +4398,12 @@
|
||||
"sourceRepoURL": "https://github.com/kazupon/vue-i18n",
|
||||
"asOfVersion": "7.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "vue-resource",
|
||||
"typingsPackageName": "vue-resource",
|
||||
"sourceRepoURL": "https://github.com/vuejs/vue-resource",
|
||||
"asOfVersion": "1.3.6"
|
||||
},
|
||||
{
|
||||
"libraryName": "vue-router",
|
||||
"typingsPackageName": "vue-router",
|
||||
|
||||
Vendored
-124
@@ -1,124 +0,0 @@
|
||||
// Type definitions for vue-resoure 0.9.3
|
||||
// Project: https://github.com/vuejs/vue-resource
|
||||
// Definitions by: kaorun343 <https://github.com/kaorun343>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="vue" />
|
||||
|
||||
declare namespace vuejs {
|
||||
|
||||
interface HttpHeaders {
|
||||
put?: { [key: string]: string };
|
||||
post?: { [key: string]: string };
|
||||
patch?: { [key: string]: string };
|
||||
delete?: { [key: string]: string };
|
||||
common?: { [key: string]: string };
|
||||
custom?: { [key: string]: string };
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
interface HttpResponse {
|
||||
data: Object;
|
||||
ok: boolean;
|
||||
status: number;
|
||||
statusText: string;
|
||||
headers: Function;
|
||||
text():string;
|
||||
json():any;
|
||||
blob():Blob;
|
||||
}
|
||||
|
||||
interface HttpOptions {
|
||||
url?: string;
|
||||
method?: string;
|
||||
body?: any;
|
||||
params?: any;
|
||||
headers?: any;
|
||||
before?(request: any): any;
|
||||
progress?(event: any): any;
|
||||
credentials?:boolean;
|
||||
emulateHTTP?: boolean;
|
||||
emulateJSON?: boolean;
|
||||
}
|
||||
|
||||
interface $http {
|
||||
(url: string, data?: any, options?: HttpOptions): PromiseLike<HttpResponse>;
|
||||
(url: string, options?: HttpOptions): PromiseLike<HttpResponse>;
|
||||
}
|
||||
|
||||
interface HttpInterceptor {
|
||||
request?(request: HttpOptions): HttpOptions;
|
||||
response?(response: HttpResponse): HttpResponse;
|
||||
}
|
||||
|
||||
interface Http {
|
||||
options: HttpOptions & { root: string };
|
||||
headers: HttpHeaders;
|
||||
interceptors: (HttpInterceptor | (() => HttpInterceptor))[];
|
||||
get: $http;
|
||||
post: $http;
|
||||
put: $http;
|
||||
patch: $http;
|
||||
delete: $http;
|
||||
jsonp: $http;
|
||||
}
|
||||
|
||||
interface ResourceActions {
|
||||
get: { method: string };
|
||||
save: { method: string };
|
||||
query: { method: string };
|
||||
update: { method: string };
|
||||
remove: { method: string };
|
||||
delete: { method: string };
|
||||
}
|
||||
|
||||
interface ResourceMethod {
|
||||
(params: any, data?: any, success?: Function, error?: Function): PromiseLike<HttpResponse>;
|
||||
(params: any, success?: Function, error?: Function): PromiseLike<HttpResponse>;
|
||||
(success?: Function, error?: Function): PromiseLike<HttpResponse>;
|
||||
}
|
||||
|
||||
interface ResourceMethods {
|
||||
get: ResourceMethod;
|
||||
save: ResourceMethod;
|
||||
query: ResourceMethod;
|
||||
update: ResourceMethod;
|
||||
remove: ResourceMethod;
|
||||
delete: ResourceMethod;
|
||||
}
|
||||
|
||||
interface $resource {
|
||||
(url: string, params?: Object, actions?: any, options?: HttpOptions): ResourceMethods;
|
||||
}
|
||||
|
||||
interface Resource extends $resource {
|
||||
actions: ResourceActions;
|
||||
}
|
||||
|
||||
interface Vue {
|
||||
$http: {
|
||||
(options: HttpOptions): PromiseLike<HttpResponse>;
|
||||
get: $http;
|
||||
post: $http;
|
||||
put: $http;
|
||||
patch: $http;
|
||||
delete: $http;
|
||||
jsonp: $http;
|
||||
};
|
||||
$resource: $resource;
|
||||
}
|
||||
|
||||
interface VueStatic {
|
||||
http: Http;
|
||||
resource: Resource;
|
||||
}
|
||||
|
||||
interface ComponentOption {
|
||||
http?: (HttpOptions & { headers?: HttpHeaders } & { [key: string]: any })
|
||||
}
|
||||
}
|
||||
|
||||
declare module "vue-resource" {
|
||||
const install: (vue: vuejs.VueStatic) => void;
|
||||
export = install;
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@types/vue": "^1.0.31"
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"vue-resource-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"npm-naming": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-construct": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-duplicate-imports": false,
|
||||
"no-duplicate-variable": false,
|
||||
"no-empty-interface": false,
|
||||
"no-for-in-array": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-irregular-whitespace": false,
|
||||
"no-mergeable-namespace": false,
|
||||
"no-misused-new": false,
|
||||
"no-namespace": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-reference-import": false,
|
||||
"no-relative-import-in-test": false,
|
||||
"no-self-import": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-string-throw": false,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
"no-useless-files": false,
|
||||
"no-var-keyword": false,
|
||||
"no-var-requires": false,
|
||||
"no-void-expression": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-shorthand": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-const": false,
|
||||
"prefer-declare-function": false,
|
||||
"prefer-for-of": false,
|
||||
"prefer-method-signature": false,
|
||||
"prefer-template": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"space-within-parens": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"trim-file": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
|
||||
|
||||
Vue.http.options.root = '/root';
|
||||
Vue.http.headers.common['Authorization'] = 'Basic YXBpOnBhc3N3b3Jk';
|
||||
|
||||
new Vue({
|
||||
http: {
|
||||
root: '/root',
|
||||
headers: {
|
||||
Authorization: 'Basic'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Vue.http.options.emulateJSON = true;
|
||||
Vue.http.options.emulateHTTP = true;
|
||||
|
||||
class App extends Vue {
|
||||
ready() {
|
||||
this.$http({ url: '/someUrl', method: 'GET' }).then((response) => {
|
||||
//
|
||||
}, (response) => {
|
||||
//
|
||||
});
|
||||
|
||||
this.$http.get('/someUrl').then((response) => {
|
||||
const status = response.status;
|
||||
const headers = response.headers();
|
||||
response.headers('expires');
|
||||
|
||||
this.$set('someData', response.data);
|
||||
this.$set('someJsonData', response.json());
|
||||
this.$set('someTextData', response.text());
|
||||
this.$set('someBlobData', response.blob());
|
||||
});
|
||||
|
||||
var resource = this.$resource('someItem/{id}');
|
||||
resource.get({id: 1}).then((response) => {});
|
||||
resource.save({id: 1}, {item: 30}).then((responce) => {});
|
||||
}
|
||||
}
|
||||
|
||||
Vue.http.get('/someUrl', {}, {});
|
||||
|
||||
Vue.http.interceptors.push({
|
||||
request: function(request) {
|
||||
return request;
|
||||
},
|
||||
response: function(response) {
|
||||
return response;
|
||||
}
|
||||
});
|
||||
|
||||
Vue.http.interceptors.push(function() {
|
||||
return {
|
||||
request: function(request) {
|
||||
return request;
|
||||
},
|
||||
response: function(response) {
|
||||
return response;
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user