-
Notifications
You must be signed in to change notification settings - Fork 13k
Description
TypeScript Version: 2.7.0-dev.20171230
Code
The issue happens if the project has a name that failed to resolve, and has more than 256 modules. The full demo project reproducing this behavior is available in this repo.
The important parts are as follows.
We would like to import third parties in the same way as normal TypeScript modules. For example, we use jquery type definitions and import it like this:
import * as $ from 'jquery';
export default function who() { return 5; }
Assume that we have more than 256 modules like the one shown above.
The tsconfig.json is
{
"compilerOptions": {
"target": "ES2015",
"module": "amd",
"declaration": true,
"outDir": "build",
"strict": true
},
"include": [
"src/**/*.ts"
]
}
Description:
Run TypeScript in watch mode. Add an arbitrary *.js file anywhere under the project root folder.
Expected behavior:
No compilation happens.
Actual behavior:
File change detected. Starting incremental compilation...
This issue is a combination of several factors from resolutionCache.ts.
First, somehow $ name gets unresolved (even though the code compiles perfectly). For some reason, the compiler starts to watch over potential paths where the resolution might be, see resolveNamesWithLocalCache. As one of the potential locations belongs to the root folder, it effectively starts watching for changes in the root folder, recursively.
Next, when JS file is added to the folder, the watcher is triggered. Normally failedLookupDefaultExtensions is used to filter out irrelevant file changes, but it's a constant, and Extension.Js
is always included regardless of the project's decision not to compile js.
Then, invalidateResolutions is called, the decision is made to always update the project, if module names collection is larger than maxNumberOfFilesToIterateForInvalidation
.
Therefore, adding a new JavaScript file triggers the recompilation.