{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/14551","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/14551/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/14551/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/14551/events","html_url":"https://github.com/Microsoft/TypeScript/issues/14551","id":212916481,"number":14551,"title":"Changing baseUrl causes compiler not to look at @types subdirectory","user":{"login":"spion","id":502412,"avatar_url":"https://avatars3.githubusercontent.com/u/502412?v=3","gravatar_id":"","url":"https://api.github.com/users/spion","html_url":"https://github.com/spion","followers_url":"https://api.github.com/users/spion/followers","following_url":"https://api.github.com/users/spion/following{/other_user}","gists_url":"https://api.github.com/users/spion/gists{/gist_id}","starred_url":"https://api.github.com/users/spion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spion/subscriptions","organizations_url":"https://api.github.com/users/spion/orgs","repos_url":"https://api.github.com/users/spion/repos","events_url":"https://api.github.com/users/spion/events{/privacy}","received_events_url":"https://api.github.com/users/spion/received_events","type":"User","site_admin":false},"labels":[{"id":371615203,"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Working%20as%20Intended","name":"Working as Intended","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-03-09T02:20:33Z","updated_at":"2017-03-09T17:41:07Z","closed_at":null,"body":"When `baseUrl` is set in tsconfig.json, the compiler will not look into `baseUrl/@types` to try and find type definitions\r\n\r\n**TypeScript Version:**  2.2.1\r\n\r\n**Code**\r\n\r\nExample is available at:\r\n\r\nhttps://github.com/spion/ts-base-url-issue\r\n\r\nIf the \"paths\" entry is removed from tsconfig.json, the compiler is unable to find `react-dom` \r\n\r\n**Expected behavior:**\r\n\r\nCompiles fine even without a \"paths\" entry.\r\n\r\n**Actual behavior:**\r\n\r\nCompiler doesn't find the definition file if the paths config option is removed. `--trace-resolution` shows that it never tries baseUrl/@types/react-dom\r\n\r\n```\r\n======== Resolving module 'react-dom' from '/Users/spion/Documents/tests/ts-modules-broken/app/index.ts'. ========\r\nExplicitly specified module resolution kind: 'NodeJs'.\r\n'baseUrl' option is set to '/Users/spion/Documents/tests/ts-modules-broken/vendor/node_modules', using this value to resolve non-relative module name 'react-dom'\r\nResolving module name 'react-dom' relative to base url '/Users/spion/Documents/tests/ts-modules-broken/vendor/node_modules' - '/Users/spion/Documents/tests/ts-modules-broken/vendor/node_modules/react-dom'.\r\nLoading module as file / folder, candidate module location '/Users/spion/Documents/tests/ts-modules-broken/vendor/node_modules/react-dom', target file type 'TypeScript'.\r\nFile '/Users/spion/Documents/tests/ts-modules-broken/vendor/node_modules/react-dom.ts' does not exist.\r\nFile '/Users/spion/Documents/tests/ts-modules-broken/vendor/node_modules/react-dom.tsx' does not exist.\r\nFile '/Users/spion/Documents/tests/ts-modules-broken/vendor/node_modules/react-dom.d.ts' does not exist.\r\nFound 'package.json' at '/Users/spion/Documents/tests/ts-modules-broken/vendor/node_modules/react-dom/package.json'.\r\n'package.json' does not have a 'typings' field.\r\n'package.json' does not have a 'types' field.\r\nFile '/Users/spion/Documents/tests/ts-modules-broken/vendor/node_modules/react-dom/index.ts' does not exist.\r\nFile '/Users/spion/Documents/tests/ts-modules-broken/vendor/node_modules/react-dom/index.tsx' does not exist.\r\nFile '/Users/spion/Documents/tests/ts-modules-broken/vendor/node_modules/react-dom/index.d.ts' does not exist.\r\nLoading module 'react-dom' from 'node_modules' folder, target file type 'TypeScript'.\r\nDirectory '/Users/spion/Documents/tests/ts-modules-broken/app/node_modules' does not exist, skipping all lookups in it.\r\nDirectory '/Users/spion/Documents/tests/ts-modules-broken/node_modules' does not exist, skipping all lookups in it.\r\nDirectory '/Users/spion/Documents/tests/node_modules' does not exist, skipping all lookups in it.\r\nDirectory '/Users/spion/Documents/node_modules' does not exist, skipping all lookups in it.\r\nDirectory '/Users/spion/node_modules' does not exist, skipping all lookups in it.\r\nDirectory '/Users/node_modules' does not exist, skipping all lookups in it.\r\nDirectory '/node_modules' does not exist, skipping all lookups in it.\r\n'baseUrl' option is set to '/Users/spion/Documents/tests/ts-modules-broken/vendor/node_modules', using this value to resolve non-relative module name 'react-dom'\r\nResolving module name 'react-dom' relative to base url '/Users/spion/Documents/tests/ts-modules-broken/vendor/node_modules' - '/Users/spion/Documents/tests/ts-modules-broken/vendor/node_modules/react-dom'.\r\nLoading module as file / folder, candidate module location '/Users/spion/Documents/tests/ts-modules-broken/vendor/node_modules/react-dom', target file type 'JavaScript'.\r\nFile '/Users/spion/Documents/tests/ts-modules-broken/vendor/node_modules/react-dom.js' does not exist.\r\nFile '/Users/spion/Documents/tests/ts-modules-broken/vendor/node_modules/react-dom.jsx' does not exist.\r\nFound 'package.json' at '/Users/spion/Documents/tests/ts-modules-broken/vendor/node_modules/react-dom/package.json'.\r\n'package.json' has 'main' field 'index.js' that references '/Users/spion/Documents/tests/ts-modules-broken/vendor/node_modules/react-dom/index.js'.\r\nFile '/Users/spion/Documents/tests/ts-modules-broken/vendor/node_modules/react-dom/index.js' exist - use it as a name resolution result.\r\n======== Module name 'react-dom' was successfully resolved to '/Users/spion/Documents/tests/ts-modules-broken/vendor/node_modules/react-dom/index.js'. ========\r\napp/index.ts(1,22): error TS7016: Could not find a declaration file for module 'react-dom'. '/Users/spion/Documents/tests/ts-modules-broken/vendor/node_modules/react-dom/index.js' implicitly has an 'any' type.\r\n```\r\n\r\n**Workaround**\r\n\r\nAdding a paths entry gets the `@types` directory into the lookup list again:\r\n\r\n```json\r\n    \"baseUrl\": \"./vendor/node_modules\",\r\n    \"paths\": {\r\n      \"*\": [\"@types/*\", \"*\"]\r\n    }\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/285424373","html_url":"https://github.com/Microsoft/TypeScript/issues/14551#issuecomment-285424373","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/14551","id":285424373,"user":{"login":"spion","id":502412,"avatar_url":"https://avatars3.githubusercontent.com/u/502412?v=3","gravatar_id":"","url":"https://api.github.com/users/spion","html_url":"https://github.com/spion","followers_url":"https://api.github.com/users/spion/followers","following_url":"https://api.github.com/users/spion/following{/other_user}","gists_url":"https://api.github.com/users/spion/gists{/gist_id}","starred_url":"https://api.github.com/users/spion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spion/subscriptions","organizations_url":"https://api.github.com/users/spion/orgs","repos_url":"https://api.github.com/users/spion/repos","events_url":"https://api.github.com/users/spion/events{/privacy}","received_events_url":"https://api.github.com/users/spion/received_events","type":"User","site_admin":false},"created_at":"2017-03-09T17:41:07Z","updated_at":"2017-03-09T17:41:07Z","body":"@mhegazy in that case, it would be useful to add this to: https://www.typescriptlang.org/docs/handbook/module-resolution.html \r\n\r\nMoving node_modules seems to be a common requirement, and changing only baseUrl doesn't work now that we have `@types`. \r\n"}}
{"actor":{"display_login":"spion"}}