{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments/47674255","id":47674255,"diff_hunk":"@@ -298,6 +298,55 @@ namespace ts {\n                 };\r\n             }\r\n \r\n+            function createWatchedFileSet() {\r\n+                const watchedDirectories = createFileMap<FileWatcher>();\r\n+                const watchedFiles = createFileMap<(fileName: string, removed?: boolean) => void>();\r\n+                const currentDirectory = process.cwd();\r\n+\r\n+                return { addFile, removeFile };\r\n+\r\n+                function addFile(fileName: string, callback: (fileName: string, removed?: boolean) => void): WatchedFile {\r\n+                    const path = toPath(fileName, currentDirectory, getCanonicalPath);\r\n+                    const parentDirPath = toPath(ts.getDirectoryPath(fileName), currentDirectory, getCanonicalPath);\r","path":"src/compiler/sys.ts","position":31,"original_position":31,"commit_id":"602cde4cc11a960a9dabec4f4c9753c8e86004bd","original_commit_id":"602cde4cc11a960a9dabec4f4c9753c8e86004bd","user":{"login":"vladima","id":8052307,"avatar_url":"https://avatars.githubusercontent.com/u/8052307?v=3","gravatar_id":"","url":"https://api.github.com/users/vladima","html_url":"https://github.com/vladima","followers_url":"https://api.github.com/users/vladima/followers","following_url":"https://api.github.com/users/vladima/following{/other_user}","gists_url":"https://api.github.com/users/vladima/gists{/gist_id}","starred_url":"https://api.github.com/users/vladima/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vladima/subscriptions","organizations_url":"https://api.github.com/users/vladima/orgs","repos_url":"https://api.github.com/users/vladima/repos","events_url":"https://api.github.com/users/vladima/events{/privacy}","received_events_url":"https://api.github.com/users/vladima/received_events","type":"User","site_admin":false},"body":"also given that `getDirectoryPath` does not reshape its argument so `Path` should stay `Path` I think we can add an overload to `getDirectoryPath` to avoid redundant conversions: smth like this:\r\n```ts\r\n    export function getDirectoryPath(path: Path): Path;\r\n    export function getDirectoryPath(path: string): string;\r\n    export function getDirectoryPath(path: string): any {\r\n        return path.substr(0, Math.max(getRootLength(path), path.lastIndexOf(directorySeparator)));\r\n    }\r\n```","created_at":"2015-12-15T18:11:26Z","updated_at":"2015-12-15T18:11:26Z","html_url":"https://github.com/Microsoft/TypeScript/pull/6026#discussion_r47674255","pull_request_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/6026","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments/47674255"},"html":{"href":"https://github.com/Microsoft/TypeScript/pull/6026#discussion_r47674255"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/6026"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/6026","id":53199666,"html_url":"https://github.com/Microsoft/TypeScript/pull/6026","diff_url":"https://github.com/Microsoft/TypeScript/pull/6026.diff","patch_url":"https://github.com/Microsoft/TypeScript/pull/6026.patch","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/6026","number":6026,"state":"open","locked":false,"title":"Fix too many watcher instances issue","user":{"login":"zhengbli","id":1171301,"avatar_url":"https://avatars.githubusercontent.com/u/1171301?v=3","gravatar_id":"","url":"https://api.github.com/users/zhengbli","html_url":"https://github.com/zhengbli","followers_url":"https://api.github.com/users/zhengbli/followers","following_url":"https://api.github.com/users/zhengbli/following{/other_user}","gists_url":"https://api.github.com/users/zhengbli/gists{/gist_id}","starred_url":"https://api.github.com/users/zhengbli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhengbli/subscriptions","organizations_url":"https://api.github.com/users/zhengbli/orgs","repos_url":"https://api.github.com/users/zhengbli/repos","events_url":"https://api.github.com/users/zhengbli/events{/privacy}","received_events_url":"https://api.github.com/users/zhengbli/received_events","type":"User","site_admin":false},"body":"Fix #6016.\r\n\r\nInstead of creating a watcher for every single file, I create watchers only for the directory that the files are in, and matches the file change event with a list of registered files.","created_at":"2015-12-10T00:28:03Z","updated_at":"2015-12-15T18:11:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"02ced4662ea8be0aa7ed801a6333a4933139d321","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/6026/commits","review_comments_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/6026/comments","review_comment_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/6026/comments","statuses_url":"https://api.github.com/repos/Microsoft/TypeScript/statuses/602cde4cc11a960a9dabec4f4c9753c8e86004bd","head":{"label":"zhengbli:i6016","ref":"i6016","sha":"602cde4cc11a960a9dabec4f4c9753c8e86004bd","user":{"login":"zhengbli","id":1171301,"avatar_url":"https://avatars.githubusercontent.com/u/1171301?v=3","gravatar_id":"","url":"https://api.github.com/users/zhengbli","html_url":"https://github.com/zhengbli","followers_url":"https://api.github.com/users/zhengbli/followers","following_url":"https://api.github.com/users/zhengbli/following{/other_user}","gists_url":"https://api.github.com/users/zhengbli/gists{/gist_id}","starred_url":"https://api.github.com/users/zhengbli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhengbli/subscriptions","organizations_url":"https://api.github.com/users/zhengbli/orgs","repos_url":"https://api.github.com/users/zhengbli/repos","events_url":"https://api.github.com/users/zhengbli/events{/privacy}","received_events_url":"https://api.github.com/users/zhengbli/received_events","type":"User","site_admin":false},"repo":{"id":31636477,"name":"TypeScript","full_name":"zhengbli/TypeScript","owner":{"login":"zhengbli","id":1171301,"avatar_url":"https://avatars.githubusercontent.com/u/1171301?v=3","gravatar_id":"","url":"https://api.github.com/users/zhengbli","html_url":"https://github.com/zhengbli","followers_url":"https://api.github.com/users/zhengbli/followers","following_url":"https://api.github.com/users/zhengbli/following{/other_user}","gists_url":"https://api.github.com/users/zhengbli/gists{/gist_id}","starred_url":"https://api.github.com/users/zhengbli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhengbli/subscriptions","organizations_url":"https://api.github.com/users/zhengbli/orgs","repos_url":"https://api.github.com/users/zhengbli/repos","events_url":"https://api.github.com/users/zhengbli/events{/privacy}","received_events_url":"https://api.github.com/users/zhengbli/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/zhengbli/TypeScript","description":"TypeScript is a superset of JavaScript that compiles to clean JavaScript output.","fork":true,"url":"https://api.github.com/repos/zhengbli/TypeScript","forks_url":"https://api.github.com/repos/zhengbli/TypeScript/forks","keys_url":"https://api.github.com/repos/zhengbli/TypeScript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zhengbli/TypeScript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zhengbli/TypeScript/teams","hooks_url":"https://api.github.com/repos/zhengbli/TypeScript/hooks","issue_events_url":"https://api.github.com/repos/zhengbli/TypeScript/issues/events{/number}","events_url":"https://api.github.com/repos/zhengbli/TypeScript/events","assignees_url":"https://api.github.com/repos/zhengbli/TypeScript/assignees{/user}","branches_url":"https://api.github.com/repos/zhengbli/TypeScript/branches{/branch}","tags_url":"https://api.github.com/repos/zhengbli/TypeScript/tags","blobs_url":"https://api.github.com/repos/zhengbli/TypeScript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zhengbli/TypeScript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zhengbli/TypeScript/git/refs{/sha}","trees_url":"https://api.github.com/repos/zhengbli/TypeScript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zhengbli/TypeScript/statuses/{sha}","languages_url":"https://api.github.com/repos/zhengbli/TypeScript/languages","stargazers_url":"https://api.github.com/repos/zhengbli/TypeScript/stargazers","contributors_url":"https://api.github.com/repos/zhengbli/TypeScript/contributors","subscribers_url":"https://api.github.com/repos/zhengbli/TypeScript/subscribers","subscription_url":"https://api.github.com/repos/zhengbli/TypeScript/subscription","commits_url":"https://api.github.com/repos/zhengbli/TypeScript/commits{/sha}","git_commits_url":"https://api.github.com/repos/zhengbli/TypeScript/git/commits{/sha}","comments_url":"https://api.github.com/repos/zhengbli/TypeScript/comments{/number}","issue_comment_url":"https://api.github.com/repos/zhengbli/TypeScript/issues/comments{/number}","contents_url":"https://api.github.com/repos/zhengbli/TypeScript/contents/{+path}","compare_url":"https://api.github.com/repos/zhengbli/TypeScript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zhengbli/TypeScript/merges","archive_url":"https://api.github.com/repos/zhengbli/TypeScript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zhengbli/TypeScript/downloads","issues_url":"https://api.github.com/repos/zhengbli/TypeScript/issues{/number}","pulls_url":"https://api.github.com/repos/zhengbli/TypeScript/pulls{/number}","milestones_url":"https://api.github.com/repos/zhengbli/TypeScript/milestones{/number}","notifications_url":"https://api.github.com/repos/zhengbli/TypeScript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zhengbli/TypeScript/labels{/name}","releases_url":"https://api.github.com/repos/zhengbli/TypeScript/releases{/id}","created_at":"2015-03-04T03:41:12Z","updated_at":"2015-05-05T17:16:07Z","pushed_at":"2015-12-15T16:49:26Z","git_url":"git://github.com/zhengbli/TypeScript.git","ssh_url":"git@github.com:zhengbli/TypeScript.git","clone_url":"https://github.com/zhengbli/TypeScript.git","svn_url":"https://github.com/zhengbli/TypeScript","homepage":"http://www.typescriptlang.org","size":230045,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Microsoft:master","ref":"master","sha":"2f447ee005ad8970cb1af64e43b3a52efe7b4ff3","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":20929025,"name":"TypeScript","full_name":"Microsoft/TypeScript","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/TypeScript","description":"TypeScript is a superset of JavaScript that compiles to clean JavaScript output.","fork":false,"url":"https://api.github.com/repos/Microsoft/TypeScript","forks_url":"https://api.github.com/repos/Microsoft/TypeScript/forks","keys_url":"https://api.github.com/repos/Microsoft/TypeScript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/TypeScript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/TypeScript/teams","hooks_url":"https://api.github.com/repos/Microsoft/TypeScript/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/TypeScript/events","assignees_url":"https://api.github.com/repos/Microsoft/TypeScript/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/TypeScript/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/TypeScript/tags","blobs_url":"https://api.github.com/repos/Microsoft/TypeScript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/TypeScript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/TypeScript/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/TypeScript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/TypeScript/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/TypeScript/languages","stargazers_url":"https://api.github.com/repos/Microsoft/TypeScript/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/TypeScript/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/TypeScript/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/TypeScript/subscription","commits_url":"https://api.github.com/repos/Microsoft/TypeScript/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/TypeScript/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/TypeScript/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/TypeScript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/TypeScript/merges","archive_url":"https://api.github.com/repos/Microsoft/TypeScript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/TypeScript/downloads","issues_url":"https://api.github.com/repos/Microsoft/TypeScript/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/TypeScript/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/TypeScript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/TypeScript/releases{/id}","created_at":"2014-06-17T15:28:39Z","updated_at":"2015-12-15T18:04:00Z","pushed_at":"2015-12-15T18:09:50Z","git_url":"git://github.com/Microsoft/TypeScript.git","ssh_url":"git@github.com:Microsoft/TypeScript.git","clone_url":"https://github.com/Microsoft/TypeScript.git","svn_url":"https://github.com/Microsoft/TypeScript","homepage":"http://www.typescriptlang.org","size":422690,"stargazers_count":8179,"watchers_count":8179,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":971,"mirror_url":null,"open_issues_count":888,"forks":971,"open_issues":888,"watchers":8179,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/6026"},"html":{"href":"https://github.com/Microsoft/TypeScript/pull/6026"},"issue":{"href":"https://api.github.com/repos/Microsoft/TypeScript/issues/6026"},"comments":{"href":"https://api.github.com/repos/Microsoft/TypeScript/issues/6026/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/6026/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/6026/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/TypeScript/statuses/602cde4cc11a960a9dabec4f4c9753c8e86004bd"}}}}