Skip to content

Commit

Permalink
fest: add typescript definitions (#143)
Browse files Browse the repository at this point in the history
fixes #19 and #75.
  • Loading branch information
IlyaSemenov authored and pi0 committed May 21, 2018
1 parent dee0087 commit eca7298
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions index.d.ts
@@ -0,0 +1,19 @@
import { AxiosInstance, AxiosRequestConfig, AxiosPromise } from 'axios'
import Vue from 'vue'

interface NuxtAxiosInstance extends AxiosInstance {
$request<T = any>(config: AxiosRequestConfig): AxiosPromise<T>
$get<T = any>(url: string, config?: AxiosRequestConfig): AxiosPromise<T>
$delete<T = any>(url: string, config?: AxiosRequestConfig): AxiosPromise<T>
$head<T = any>(url: string, config?: AxiosRequestConfig): AxiosPromise<T>
$options<T = any>(url: string, config?: AxiosRequestConfig): AxiosPromise<T>
$post<T = any>(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise<T>
$put<T = any>(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise<T>
$patch<T = any>(url: string, data?: any, config?: AxiosRequestConfig): AxiosPromise<T>
}

declare module 'vue/types/vue' {
interface Vue {
$axios: NuxtAxiosInstance
}
}
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -4,6 +4,7 @@
"description": "Secure and easy axios integration with Nuxt.js",
"license": "MIT",
"main": "lib/module.js",
"types": "index.d.ts",
"repository": "https://github.com/nuxt-community/axios-module",
"publishConfig": {
"access": "public"
Expand Down

0 comments on commit eca7298

Please sign in to comment.