This repo is a minimal reproduction of what seems to be a bug with the
TypeScript compiler's watch mode. For some reason, this particular set of
dependencies in package.json
causes tsc
to watch files that aren't targeted
for compilation.
I submitted an issue that references this repo.
2018-04-28 update: One of the TypeScript developers looked into it and replied with an explanation of the behavior. The root directory is watched in case new files are added, and there is a cap of 250 files for TypeScript to check if files actually affect module resolution. So removing a dependency in this repo fixes the issue because it reduces the number of files to below that limit.
- I used Node v8.6.0, Yarn v1.5.1, and TypeScript v2.8.1.
- Clone this repo, and run
yarn install
. - Run
yarn tsc -w
oryarn tsc -w src/foo.ts
. The bug should occur either way. - Make a change in
package.json
,bar.js
, ornode_modules/ioredis/index.js
, and save. - tsc should update with:
File change detected. Starting incremental compilation...
tsc
seems to process the type definitions innode_modules
, even thoughfoo.ts
doesn't import any package. This behavior was surprising to me.- I originally ran into this issue in a project repo. I attempted to trim down the dependencies to a single offending one, but it seems like something about this combination is not good. Removing any more dependencies fixed the issue during my testing.
- I tried using
typescript@next
, but the issue still occurs.