{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments/36258615","id":36258615,"diff_hunk":"@@ -158,24 +222,57 @@ namespace ts {\n         let start = new Date().getTime();\r\n \r\n         host = host || createCompilerHost(options);\r\n+        \r\n+        // initialize resolveModuleNameWorker only if noResolve is false\r\n+        let resolveModuleNamesWorker: (moduleNames: string[], containingFile: string) => string[];\r\n+        if (!options.noResolve) {\r\n+            resolveModuleNamesWorker = host.resolveModuleNames;\r\n+            if (!resolveModuleNamesWorker) {\r\n+                Debug.assert(host.getModuleResolutionHost !== undefined);\r","path":"src/compiler/program.ts","position":115,"original_position":115,"commit_id":"a72994d78ce318faaaf9e9ecbd04622ffc4fcefd","original_commit_id":"a72994d78ce318faaaf9e9ecbd04622ffc4fcefd","user":{"login":"mhegazy","id":8000722,"avatar_url":"https://avatars.githubusercontent.com/u/8000722?v=3","gravatar_id":"","url":"https://api.github.com/users/mhegazy","html_url":"https://github.com/mhegazy","followers_url":"https://api.github.com/users/mhegazy/followers","following_url":"https://api.github.com/users/mhegazy/following{/other_user}","gists_url":"https://api.github.com/users/mhegazy/gists{/gist_id}","starred_url":"https://api.github.com/users/mhegazy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhegazy/subscriptions","organizations_url":"https://api.github.com/users/mhegazy/orgs","repos_url":"https://api.github.com/users/mhegazy/repos","events_url":"https://api.github.com/users/mhegazy/events{/privacy}","received_events_url":"https://api.github.com/users/mhegazy/received_events","type":"User","site_admin":false},"body":"As we discussed, i think this should be directly on the host. this way you will get a compile-time error.","created_at":"2015-08-05T00:25:42Z","updated_at":"2015-08-05T00:25:42Z","html_url":"https://github.com/Microsoft/TypeScript/pull/4154#discussion_r36258615","pull_request_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/4154","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments/36258615"},"html":{"href":"https://github.com/Microsoft/TypeScript/pull/4154#discussion_r36258615"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/4154"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/4154","id":41626109,"html_url":"https://github.com/Microsoft/TypeScript/pull/4154","diff_url":"https://github.com/Microsoft/TypeScript/pull/4154.diff","patch_url":"https://github.com/Microsoft/TypeScript/pull/4154.patch","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/4154","number":4154,"state":"open","locked":false,"title":"Revised module resolution","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":"This PR consolidates all module resolution logic in one place so there is only one entry point for everything that needs to resolve module names. Currently it is function `getDefaultModuleNameResolver` function that accepts `CompilerOptions` and returns back an instance of `ModuleResolved` which is the alias for `export type ModuleNameResolver = (moduleName: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost) => ResolvedModule;`. Default module resolver is used in several places:\r\n- `preProcessFile` that is called from VS to determine dependencies of the file\r\n- `createProgram` - at this point default module resolver will be requested if host wants to process with default module name resolution rules. NOTE: host can override built-in rules by implementing `resolveModuleNames?(moduleNames: string[], containingFile: string): string[];` function that accepts a list of imported names in the file and returns a list of resolved file names in the same order.\r\n- `resolveModuleNames` implementation in `LSHost` for 'tsserver'.\r\n\r\nNow `CompilerHost / LanguageServiceHost` can implement `resolveModuleNames` and be completely in control of how module names are resolved. Alternatively they might want to use built-in rules - in this case they should implement `getModuleResolutionHost`, return value of this function will be used by default module resolver to ask file system related questions. ","created_at":"2015-08-04T22:40:10Z","updated_at":"2015-08-05T00:25:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"232b00fb0272fc5866a3592d94b5730d79d408ce","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/4154/commits","review_comments_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/4154/comments","review_comment_url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/4154/comments","statuses_url":"https://api.github.com/repos/Microsoft/TypeScript/statuses/a72994d78ce318faaaf9e9ecbd04622ffc4fcefd","head":{"label":"Microsoft:reuseAndCache","ref":"reuseAndCache","sha":"a72994d78ce318faaaf9e9ecbd04622ffc4fcefd","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-08-04T18:38:38Z","pushed_at":"2015-08-04T22:47:18Z","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":961268,"stargazers_count":6172,"watchers_count":6172,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":679,"mirror_url":null,"open_issues_count":754,"forks":679,"open_issues":754,"watchers":6172,"default_branch":"master"}},"base":{"label":"Microsoft:master","ref":"master","sha":"bb3fb7d98b4ac4cd62474dde15c226b26af30b5f","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-08-04T18:38:38Z","pushed_at":"2015-08-04T22:47:18Z","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":961268,"stargazers_count":6172,"watchers_count":6172,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":679,"mirror_url":null,"open_issues_count":754,"forks":679,"open_issues":754,"watchers":6172,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/4154"},"html":{"href":"https://github.com/Microsoft/TypeScript/pull/4154"},"issue":{"href":"https://api.github.com/repos/Microsoft/TypeScript/issues/4154"},"comments":{"href":"https://api.github.com/repos/Microsoft/TypeScript/issues/4154/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/4154/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/TypeScript/pulls/4154/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/TypeScript/statuses/a72994d78ce318faaaf9e9ecbd04622ffc4fcefd"}}}}