mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-11-29 17:51:46 +00:00
Use namespace to add tokenCache as prop of default export function
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import tokenProvider, { tokenCache } from 'axios-token-interceptor';
|
||||
import tokenProvider from 'axios-token-interceptor';
|
||||
|
||||
tokenProvider(); // $ExpectError
|
||||
|
||||
@@ -13,6 +13,6 @@ const getToken = Promise.resolve('qwerty');
|
||||
const validCacheOptions = {
|
||||
maxAge: 3600,
|
||||
};
|
||||
const cache = tokenCache(getToken, validCacheOptions); // $Expect TokenCache
|
||||
const cache = tokenProvider.tokenCache(getToken, validCacheOptions); // $Expect TokenCache
|
||||
|
||||
cache.reset(); // $ExpectType void
|
||||
|
||||
+7
-5
@@ -5,13 +5,15 @@
|
||||
|
||||
import { AxiosRequestConfig } from 'axios';
|
||||
|
||||
/*~ If this module has methods, declare them as functions like so.
|
||||
*/
|
||||
// Module
|
||||
export function AxiosTokenProvider(Options: InterceptorOptions): TokenProvider;
|
||||
export namespace AxiosTokenProvider {
|
||||
function tokenCache(getToken: Promise<string>, options: TokenCacheOptions): TokenCache;
|
||||
}
|
||||
export default AxiosTokenProvider;
|
||||
|
||||
export default function tokenProvider(Options: InterceptorOptions): TokenProvider;
|
||||
export function tokenCache(getToken: Promise<string>, options: TokenCacheOptions): TokenCache;
|
||||
// Interfaces
|
||||
|
||||
/*~ You can declare types that are available via importing the module */
|
||||
export interface InterceptorOptions {
|
||||
token?: string;
|
||||
getToken?: () => string | Promise<string>;
|
||||
|
||||
Reference in New Issue
Block a user