Title: Creating *.js files anywhere under the project root triggers recompilation in watch mode for big projects having an unresolved name · Issue #20934 · microsoft/TypeScript · GitHub
Open Graph Title: Creating *.js files anywhere under the project root triggers recompilation in watch mode for big projects having an unresolved name · Issue #20934 · microsoft/TypeScript
X Title: Creating *.js files anywhere under the project root triggers recompilation in watch mode for big projects having an unresolved name · Issue #20934 · microsoft/TypeScript
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...
Open Graph 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 ava...
X 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 ava...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/20934
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Creating *.js files anywhere under the project root triggers recompilation in watch mode for big projects having an unresolved name","articleBody":"**TypeScript Version:** 2.7.0-dev.20171230\r\n**Code**\r\nThe 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](https://github.com/ogvolkov/ts-mystery-watch-issue).\r\n\r\nThe important parts are as follows.\r\n\r\nWe 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:\r\n```ts\r\nimport * as $ from 'jquery';\r\nexport default function who() { return 5; }\r\n```\r\nAssume that we have more than 256 modules like the one shown above.\r\n\r\nThe tsconfig.json is\r\n```\r\n{\r\n \"compilerOptions\": {\r\n \"target\": \"ES2015\",\r\n \"module\": \"amd\",\r\n \"declaration\": true,\r\n \"outDir\": \"build\",\r\n \"strict\": true\r\n },\r\n \"include\": [\r\n \"src/**/*.ts\"\r\n ]\r\n}\r\n```\r\n**Description:**\r\nRun TypeScript in watch mode. Add an arbitrary *.js file anywhere under the project root folder.\r\n\r\n**Expected behavior:**\r\nNo compilation happens.\r\n\r\n**Actual behavior:**\r\nFile change detected. Starting incremental compilation...\r\n\r\nThis issue is a combination of several factors from [resolutionCache.ts](https://github.com/Microsoft/TypeScript/blob/master/src/compiler/resolutionCache.ts).\r\n\r\nFirst, 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](https://github.com/Microsoft/TypeScript/blob/fd415214219476754bd89c2f707b0e794451a076/src/compiler/resolutionCache.ts#L254). As one of the potential locations belongs to the root folder, it effectively starts watching for changes in the root folder, recursively.\r\n\r\nNext, when JS file is added to the folder, the watcher is triggered. Normally [failedLookupDefaultExtensions ](https://github.com/Microsoft/TypeScript/blob/0477f91dbad209809363323042f34926d3a6e175/src/compiler/resolutionCache.ts#L97)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.\r\n\r\nThen, [invalidateResolutions ](https://github.com/Microsoft/TypeScript/blob/0477f91dbad209809363323042f34926d3a6e175/src/compiler/resolutionCache.ts#L532) is called, the decision is made to always update the project, if module names collection is larger than `maxNumberOfFilesToIterateForInvalidation`.\r\n\r\nTherefore, adding a new JavaScript file triggers the recompilation.","author":{"url":"https://github.com/ogvolkov","@type":"Person","name":"ogvolkov"},"datePublished":"2017-12-29T10:11:23Z","url":"https://github.com/microsoft/TypeScript/issues/20934"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:300e0f83-70de-df3d-2590-c3afea2d9f70 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DF92:28DAC6:2065BE8:2965361:6B03E3B7 |
| html-safe-nonce | 4079bac45e9c495261c0d7ce2bb16c9898f8cd59b6e5e240e3939fafbbcf4bb4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERjkyOjI4REFDNjoyMDY1QkU4OjI5NjUzNjE6NkIwM0UzQjciLCJ2aXNpdG9yX2lkIjoiMTk4NjM5NzE2OTAzMjM1Njc5MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a25872ceb26f2acdf23e6102d418beb4597c660d1e9f500db07517b15033fba5 |
| hovercard-subject-tag | issue:285067488 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/20934/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1e5687ddaa7d4857ec00385bf8e1b34493256a4e808055969f10fbe675af5b37/microsoft/TypeScript/issues/20934 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1e5687ddaa7d4857ec00385bf8e1b34493256a4e808055969f10fbe675af5b37/microsoft/TypeScript/issues/20934 |
| og:image:alt | 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 ava... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ogvolkov |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width