microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
98.27k stars 12.21k forks source link

Watch cannot handle large amount of file changes #58342

Open 2767mr opened 2 weeks ago

2767mr commented 2 weeks ago

πŸ”Ž Search Terms

watch, tsc, tsserver, files, Cannot find module, or its corresponding type declarations

πŸ•— Version & Regression Information

⏯ Playground Link

https://github.com/2767mr/tsbug

πŸ’» Code

No response

πŸ™ Actual behavior

After deleting and regenerating a large amount of auto-generated files, typescript reports an error as seen below when using --watch. This also affects the VS Code tsserver.

src/main.ts:1:32 - error TS2307: Cannot find module './app/services/generated' or its corresponding type declarations.

1 import { TranslationDto } from "./app/services/generated";

πŸ™‚ Expected behavior

Typescript should pick up new files even when there are a lot of them.

Additional information about the issue

Reproduction:

  1. Clone https://github.com/2767mr/tsbug
  2. npm install
  3. Open one terminal with npm run watch
  4. After a few seconds, open another terminal with npm run copy

Here is the tsserver log that is created when doing this: tsserver.log

Possibly related issues:

57330

22710

37514

54511 (same use case as we have - but on our end it does not work at all instead of being slow)

2767mr commented 2 weeks ago

Note that this bug does not happen if you reduce the amount of files that will be copied by npm run copy