From f84c409201944dcbaab97629fb60f3936bd437f5 Mon Sep 17 00:00:00 2001 From: hzGotB Date: Fri, 13 Mar 2020 11:13:27 +0800 Subject: [PATCH] =?UTF-8?q?OnionMiddleware=20=E7=9A=84=20next=20=E5=BA=94?= =?UTF-8?q?=E8=AF=A5=E6=98=AF=E8=BF=94=E5=9B=9E=E4=B8=80=E4=B8=AA=20Promis?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit OnionMiddleware 的 next 应该是返回一个 Promise,这样在 ts 中 await 时就不会提示`'await' has no effect on the type of this expression.ts(80007)` --- types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/index.d.ts b/types/index.d.ts index 4fd08c5..45fb206 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -76,7 +76,7 @@ export interface Context { export type ResponseInterceptor = (response: Response, options: RequestOptionsInit) => Response | Promise; -export type OnionMiddleware = (ctx: Context, next: () => void) => void; +export type OnionMiddleware = (ctx: Context, next: () => Promise) => void; export type OnionOptions = { global?: boolean; core?: boolean; defaultInstance?: boolean }; export interface RequestMethod {