chore: 隐藏内部使用类型

pull/49/head
zjx0905 2023-05-14 21:44:08 +08:00
parent a1281f86a5
commit 3f4a8a12e0
5 changed files with 40 additions and 25 deletions

View File

@ -501,7 +501,29 @@ export default class Axios {
/** /**
* *
* *
* @param middleware * 1
* ```ts
* axios.use(async function middleware(ctx, next) {
* console.log(ctx.req);
* await next();
* console.log(ctx.res);
* });
* ```
*
* 2
* ```ts
* axios
* .use(async function middleware1(ctx, next) {
* console.log(ctx.req);
* await next();
* console.log(ctx.res);
* })
* .use(async function middleware2(ctx, next) {
* console.log(ctx.req);
* await next();
* console.log(ctx.res);
* });
* ```
*/ */
use = (middleware: MiddlewareCallback) => { use = (middleware: MiddlewareCallback) => {
this.#middleware.use(middleware); this.#middleware.use(middleware);

View File

@ -39,6 +39,8 @@ export default class InterceptorManager<T = unknown> {
#interceptors = new Map<number, Interceptor<T>>(); #interceptors = new Map<number, Interceptor<T>>();
/** /**
* @internal
*
* *
*/ */
get size() { get size() {
@ -81,6 +83,8 @@ export default class InterceptorManager<T = unknown> {
} }
/** /**
* @internal
*
* *
* *
* @param executor * @param executor

View File

@ -40,30 +40,6 @@ export default class MiddlewareManager {
/** /**
* *
*
* 1
* ```ts
* axios.use(async function middleware(ctx, next) {
* console.log(ctx.req);
* await next();
* console.log(ctx.res);
* });
* ```
*
* 2
* ```ts
* axios
* .use(async function middleware1(ctx, next) {
* console.log(ctx.req);
* await next();
* console.log(ctx.res);
* })
* .use(async function middleware2(ctx, next) {
* console.log(ctx.req);
* await next();
* console.log(ctx.res);
* });
* ```
*/ */
use(middleware: MiddlewareCallback) { use(middleware: MiddlewareCallback) {
assert(isFunction(middleware), 'middleware 不是一个 function'); assert(isFunction(middleware), 'middleware 不是一个 function');
@ -71,6 +47,8 @@ export default class MiddlewareManager {
} }
/** /**
* @internal
*
* *
*/ */
createContext(config: AxiosRequestConfig): MiddlewareContext { createContext(config: AxiosRequestConfig): MiddlewareContext {
@ -81,6 +59,8 @@ export default class MiddlewareManager {
} }
/** /**
* @internal
*
* *
* *
* @param ctx * @param ctx
@ -95,6 +75,8 @@ export default class MiddlewareManager {
} }
/** /**
* @internal
*
* *
* *
* @param enhancer * @param enhancer

View File

@ -46,6 +46,9 @@ export function isCancel(value: unknown): value is Cancel {
export class CancelToken { export class CancelToken {
#reason?: Cancel; #reason?: Cancel;
/**
* @internal
*/
onCancel: Promise<Cancel>['then']; onCancel: Promise<Cancel>['then'];
constructor(executor: CancelExecutor) { constructor(executor: CancelExecutor) {
@ -79,6 +82,9 @@ export class CancelToken {
}; };
} }
/**
* @internal
*/
throwIfRequested(): void { throwIfRequested(): void {
if (this.#reason) { if (this.#reason) {
throw this.#reason; throw this.#reason;

View File

@ -7,6 +7,7 @@
"module": "ESNext", "module": "ESNext",
"strict": true, "strict": true,
"noEmit": true, "noEmit": true,
"stripInternal": true,
"moduleResolution": "node", "moduleResolution": "node",
"skipLibCheck": true, "skipLibCheck": true,
"skipDefaultLibCheck": true, "skipDefaultLibCheck": true,