opensource
opensource copied to clipboard
koa-better-body types are broken
Support plan
- which support plan is this issue covered by? (e.g. Community, Sponsor, or Enterprise): Community
- is this issue currently blocking your project? (no): no
- is this issue affecting a production system? (no): no
Context
- node version: 12.16.3
- module version: koa-better-body 3.3.9
- environment (e.g. node, browser, native): node
- used with (i.e. popular names of modules): Koa
- any other relevant information:
What are you trying to achieve or the steps to reproduce?
Use koa-better-body with typescript
What was the result you got?
@types/koa-better-body says that types are already included with koa-better-body but they are not
What result did you expect?
A type definition file, either at koa-better-body or at @types/koa-better-body
Thank you for raising this issue! We will try and get back to you as soon as possible. Please make sure you format it properly, followed our code of conduct, and have given us as much context as possible. Hey @tunnckoCore, check out this one too! ;)
Hi there. I think I received such issue previously. I think there was a PR there to revert back to the old version. Can't follow now, probably in the coming days.
The v3.2.x is nothing new. You can use the 3.1.x or 3.0.x types.
There are 3.0 types but they don't seem to be complete. I ended up using a different solution, thought I would let you know though!
Yea, thanks, I should fix that. I had it in mind.
I'm also running into this issue. I was using 3.0.4
and the types did not seem to be included. I also tried using 3.3.9
and 3.1.15
.
@stevebaxter what was the different solution you found?
@macsj200 I was using 3.0.4
Just continue using them? Nothing has changed in the versions from last year, year-and-a-half.
@macsj200 - I needed the raw body, I ended up unpacking it myself with raw-body, e.g.:
import getRawBody from "raw-body";
.
.
.
public async handleRequest(ctx: Context): Promise<void> {
const rawBody = await getRawBody(ctx.req, { limit: "50mb", length: ctx.request.length });
// Do something with the raw body...
}
@tunnckoCore when you say "continue using them" what do you mean? Like I said, the types did not seem to be included in 3.0.4
.
Ah sorry, misread it.
No worries, let me know if there's a solution you can think of or if you think I'm just doing something wrong.
Currently I'm thinking I will just have to shoehorn some custom types in the app code and use as
typecasts to get around these issues, but obviously it's much cleaner to use the library-supplied types where possible.