koajs / koa-body

koa body parser middleware
MIT License
950 stars 130 forks source link

More specific body type definition #119

Closed edevil closed 5 years ago

edevil commented 6 years ago

Addresses #118.

MarkHerhold commented 6 years ago

This seems reasonable enough to me.

Pinging @egilsster @damianb @ErikAugust and @naxmefy who have PR'd prior fixes for type definitions for comments/feedback

egilsster commented 6 years ago

This is going to cause errors where you are accessing properties on the body object since it contains no key index, so I think something along the lines of body: { [key: string]: any } | null | undefined gives us a clearer picture of what this object might be. That said, that will require a set of PRs for the other libraries in question to solve your issue here.

katanacrimson commented 6 years ago

Dug into why koa-bodyparser's typings are how they are currently. They changed, recently, from any to that weird typing, which honestly I really don't care for. It renders koa-bodyparser much harder to use all for the sake of (poorly) emulating a feature to come in later-coming typescript versions (ugh).

https://github.com/DefinitelyTyped/DefinitelyTyped/pull/26330

katanacrimson commented 5 years ago

The changes in koa-bodyparser's typings, by the way, have since been reverted: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/90961b6110f9848311859f25b600d9e25e9bd783/types/koa-bodyparser/index.d.ts#L21-L26

Revert happened in this PR on DT'd: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/30569

This PR should be closed, IMO.

MarkHerhold commented 5 years ago

Thanks @damianb!

bag-man commented 5 years ago

npm i --save-dev @types/koa-bodyparser@latest