问题描述
Koa中间件类型定义
// @types/koa
type Middleware<StateT = DefaultState,CustomT = DefaultContext> = compose.Middleware<
ParameterizedContext<StateT,CustomT>
>;
期望
// src/middleware/cookie.ts
import { ExtendableContext,Middleware } from "koa";
type CookieContext = ExtendableContext & {
cookie: string;
}
const parseCookieMiddleware: Middleware</*wanna skip passing generic here to use default type(DefaultState)*/,CookieContext> = async (ctx,next) => {
//parse cookie here
await next();
};
我可以通过DefaultState或创建wrapdMiddlewareType,
但是Koa类型定义为我们提供了默认值。
所以我只想跳过不必要的步骤。
感谢您的阅读。
祝你有美好的一天!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)