定义了一个interface,但是检测不了类型
export interface Base { token: string; // token source?: number; // 来源 mk: string; // 随机唯一码 ct: string; // 随机字符串 [propName: string]: any; };export interface OrderCancel extends Base { ids: string[]; }async cancel() { const {ctx, service} = this; const reqBody: OrderCancel = ctx.request.body; ctx.body = await service.order.cancel(reqBody); ctx.code = 0; }
我期望的是request.body
传入的值匹配OrderCancel
这个接口,对传入参数进行检验,但是请求的时候发现所有请求都可以过,没有检测类型,但是直接按照下面赋值的话,就有检测
const {ctx, service} = this; const reqBody: OrderCancel = { token: 123 }; ctx.body = await service.order.cancel(reqBody); ctx.code = 0;
求解答,求帮助
森栏
相关分类