koajs / koa-body

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

fix(typescript): declaration file #175

Closed Seldszar closed 4 years ago

Seldszar commented 4 years ago

When installing the package, the ambient declaration didn't seem to be applied. I updated the file by using the same approach as the koa-bodyparser package does (https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/koa-bodyparser/index.d.ts). After this change, I was able to access the body and files properties.

Eusen commented 4 years ago

What typescript version do you use? Have you compiled in ^3.8.2 ?

Seldszar commented 4 years ago

Tried with 3.8.3 and 3.9.2.

Eusen commented 4 years ago

It's look good to me! But I think it might be better if we can add ts related notes to readme! like this:

If you use typescript, you need to append an option in tsconfig.json: { "compilerOptions": { "esModuleInterop": true } }

MarkHerhold commented 4 years ago

related to #177

MarkHerhold commented 4 years ago

@Seldszar I created a TS integration directory at /test/ts-module-integration that uses the same version of TS but it seems to have access to body. Could you please check to see if this is the case for you as well?

image

Seldszar commented 4 years ago

Tested just now and I have access to body as well.

MarkHerhold commented 4 years ago

I'm going to close this until we determine that this or another type change is needed. Thanks!