opensource icon indicating copy to clipboard operation
opensource copied to clipboard

koa-better-body types are broken

Open stevebaxter opened this issue 4 years ago • 10 comments

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

stevebaxter avatar Jul 23 '20 17:07 stevebaxter

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! ;)

auto-comment[bot] avatar Jul 23 '20 17:07 auto-comment[bot]

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.

tunnckoCore avatar Jul 23 '20 19:07 tunnckoCore

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!

stevebaxter avatar Jul 24 '20 07:07 stevebaxter

Yea, thanks, I should fix that. I had it in mind.

tunnckoCore avatar Jul 28 '20 13:07 tunnckoCore

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 avatar Aug 13 '20 18:08 macsj200

@macsj200 I was using 3.0.4

Just continue using them? Nothing has changed in the versions from last year, year-and-a-half.

tunnckoCore avatar Aug 14 '20 09:08 tunnckoCore

@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...
  }

stevebaxter avatar Aug 14 '20 09:08 stevebaxter

@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.

macsj200 avatar Aug 14 '20 14:08 macsj200

Ah sorry, misread it.

tunnckoCore avatar Aug 15 '20 00:08 tunnckoCore

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.

macsj200 avatar Aug 16 '20 20:08 macsj200