mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 12:11:47 +00:00
Update axios-token-interceptor type definitions to match latest version (#40945)
* Update axios-token-interceptor type definitions to match latest version * Add mgdodge to 'definitions by' as per @andrewbranch sugggestion
This commit is contained in:
@@ -2,17 +2,22 @@ import tokenProvider = require('axios-token-interceptor');
|
||||
|
||||
tokenProvider(); // $ExpectError
|
||||
|
||||
const validOptions = {
|
||||
const validOptions1 = {
|
||||
getToken: () => 'qwerty',
|
||||
};
|
||||
tokenProvider(validOptions1); // $ExpectType TokenProvider
|
||||
|
||||
const validOptions2 = {
|
||||
getToken: () => Promise.resolve('qwerty'),
|
||||
};
|
||||
tokenProvider(validOptions); // $ExpectType TokenProvider
|
||||
tokenProvider(validOptions2); // $ExpectType TokenProvider
|
||||
|
||||
tokenCache(); // $ExpectError
|
||||
tokenProvider.tokenCache(); // $ExpectError
|
||||
|
||||
const getToken = Promise.resolve('qwerty');
|
||||
const validCacheGetter = () => Promise.resolve('qwerty');
|
||||
const validCacheOptions = {
|
||||
maxAge: 3600,
|
||||
};
|
||||
const cache = tokenProvider.tokenCache(getToken, validCacheOptions); // $Expect TokenCache
|
||||
const cache = tokenProvider.tokenCache(validCacheGetter, validCacheOptions); // $Expect TokenCache
|
||||
|
||||
cache.reset(); // $ExpectType void
|
||||
|
||||
+5
-3
@@ -1,6 +1,7 @@
|
||||
// Type definitions for axios-token-interceptor 0.1
|
||||
// Type definitions for axios-token-interceptor 0.2
|
||||
// Project: https://github.com/sandrinodimattia/axios-token-interceptor#readme
|
||||
// Definitions by: Mike Dodge <https://github.com/innovation-team>
|
||||
// Definitions by: Vivint Team Innovation <https://github.com/innovation-team>
|
||||
// Mike Dodge <https://github.com/mgdodge>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -9,7 +10,7 @@ import { AxiosRequestConfig } from 'axios';
|
||||
// Module
|
||||
declare function AxiosTokenProvider(Options: AxiosTokenProvider.InterceptorOptions): AxiosTokenProvider.TokenProvider;
|
||||
declare namespace AxiosTokenProvider {
|
||||
function tokenCache(getToken: Promise<string>, options: TokenCacheOptions): TokenCache;
|
||||
function tokenCache(getToken: () => Promise<string>, options: TokenCacheOptions): TokenCache;
|
||||
|
||||
// Interfaces
|
||||
interface InterceptorOptions {
|
||||
@@ -27,6 +28,7 @@ declare namespace AxiosTokenProvider {
|
||||
}
|
||||
|
||||
interface TokenCache {
|
||||
(): Promise<string>;
|
||||
reset(): void;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user