koajs / koa-body

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

typescript build error: Invalid module name in augmentation #182

Open HCLQ opened 4 years ago

HCLQ commented 4 years ago

Problem/Feature Request Summary

Environment Information

Current Behavior

see the error

node_modules/koa-body/index.d.ts:4:16 - error TS2665: Invalid module name in augmentation. Module 'koa' resolves to an untyped module at '/Users/hcl/code/node/yapi/vender/node_modules/koa/lib/application.js', which cannot be augmented.

4 declare module "koa" {



Found 1 error.

## Steps to Reproduce
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
<!--- reproduce this bug. Include code to reproduce, if relevant. -->
1. open shell
2. tsc
3.

## Expected Behavior
no error

## Possible Solution
<!--- Not obligatory, but suggest a fix -->

## Context (Environment)
<!--- How has this issue affected you? What are you trying to accomplish? -->
<!--- Providing context helps us come up with a solution that is most useful in the real world -->

<!--- Provide a general summary of the issue in the Title above -->
MarkHerhold commented 4 years ago

Could you please provide a very minimal project (zip, github repo, or set of files) where this fails so we can reproduce the issue?

heiemooa commented 3 years ago

Question

Hi, when i run 'npx tsc', I also received an errors like "Invalid module name in augmentation. Module 'koa' resolves to an untyped module at 'xxxxxxxxx/node_modules/koa/lib/application.js', which cannot be augmented"

Demo

const router = new Router() const app = new Koa();

app.use(koaBody()).use(router.routes());

app.listen(3000)

$ npx tsc demo.ts

## result

../node_modules/koa-body/index.d.ts:4:16 - error TS2665: Invalid module name in augmentation. Module 'koa' resolves to an untyped module at '/Users/***/node_modules/koa/lib/application.js', which cannot be augmented.

4 declare module "koa" {



```

## Version
```
koa-body: 4.2.0
Koa: 2.13.0
Node.js: 12.22.1
TypeScript: 4.1.3
```