koa-body
koa-body copied to clipboard
Property 'files' or 'body' does not exist on type 'Request'
Problem/Feature Request Summary
when my context is custom and use koa-body in typesciprt, Property 'files' does not exist on type 'Request' or Property 'body' does not exist on type 'Request'
Environment Information
- koa-body:^4.1.1
- Koa: ^2.11.0
- Node.js:10.13.0
Current Behavior
Steps to Reproduce
Expected Behavior
Possible Solution
Context (Environment)
Same issue here. @southorange1228, are you by any chance using pnpm
too?
i just custom interface in order to solve this problem.
export interface SoRequest extends Request {
body?: any;
files?: Files;
}
export interface SoContext extends Koa.Context {
request: SoRequest;
}
and i never use pnpm
version:5.0.0 pnpm also bugs,please fix
maybe you should define the middleware Type import { MiddleWare } from '@koa/router' type Middleware from @koa/router or koa
// xxx.ts
interface BodyType {
// whatever
}
const controller: Middleware = async (ctx) => {
const body = ctx.request.body as BodyType
// something
}
app.use(controller)
Problem still exists Version: 6.0.1