diff --git a/types/lifeomic__axios-fetch/index.d.ts b/types/lifeomic__axios-fetch/index.d.ts new file mode 100644 index 0000000000..cfe0c221b7 --- /dev/null +++ b/types/lifeomic__axios-fetch/index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for @lifeomic/axios-fetch 1.4 +// Project: https://github.com/lifeomic/axios-fetch +// Definitions by: Jason Di Benedetto +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { Response, RequestInfo, RequestInit } from 'node-fetch'; +import { AxiosInstance, AxiosTransformer } from 'axios'; + +export function buildAxiosFetch( + axios: AxiosInstance, + transformer?: AxiosTransformer, +): (url: RequestInfo, init?: RequestInit) => Promise; diff --git a/types/lifeomic__axios-fetch/lifeomic__axios-fetch-tests.ts b/types/lifeomic__axios-fetch/lifeomic__axios-fetch-tests.ts new file mode 100644 index 0000000000..387b875f04 --- /dev/null +++ b/types/lifeomic__axios-fetch/lifeomic__axios-fetch-tests.ts @@ -0,0 +1,18 @@ +import axios from 'axios'; +import { buildAxiosFetch } from '@lifeomic/axios-fetch'; + +const instance = axios.create(); + +const fetch = buildAxiosFetch(instance, config => { + config.timeout = 1000; + return config; +}); + +fetch('https://jsonplaceholder.typicode.com/users', { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, +}).then(response => { + return response.json(); +}); diff --git a/types/lifeomic__axios-fetch/package.json b/types/lifeomic__axios-fetch/package.json new file mode 100644 index 0000000000..463ef8de66 --- /dev/null +++ b/types/lifeomic__axios-fetch/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "axios": "^0.19.0" + } +} diff --git a/types/lifeomic__axios-fetch/tsconfig.json b/types/lifeomic__axios-fetch/tsconfig.json new file mode 100644 index 0000000000..e31be3aa63 --- /dev/null +++ b/types/lifeomic__axios-fetch/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "paths": { + "@lifeomic/axios-fetch": [ + "lifeomic__axios-fetch" + ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "lifeomic__axios-fetch-tests.ts" + ] +} diff --git a/types/lifeomic__axios-fetch/tslint.json b/types/lifeomic__axios-fetch/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/lifeomic__axios-fetch/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }