{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/6427","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/6427/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/6427/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/6427/events","html_url":"https://github.com/Microsoft/TypeScript/issues/6427","id":125794165,"number":6427,"title":"Node module resolution resolving regardless of `typings` field","user":{"login":"blakeembrey","id":1088987,"avatar_url":"https://avatars.githubusercontent.com/u/1088987?v=3","gravatar_id":"","url":"https://api.github.com/users/blakeembrey","html_url":"https://github.com/blakeembrey","followers_url":"https://api.github.com/users/blakeembrey/followers","following_url":"https://api.github.com/users/blakeembrey/following{/other_user}","gists_url":"https://api.github.com/users/blakeembrey/gists{/gist_id}","starred_url":"https://api.github.com/users/blakeembrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blakeembrey/subscriptions","organizations_url":"https://api.github.com/users/blakeembrey/orgs","repos_url":"https://api.github.com/users/blakeembrey/repos","events_url":"https://api.github.com/users/blakeembrey/events{/privacy}","received_events_url":"https://api.github.com/users/blakeembrey/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2016-01-10T02:32:50Z","updated_at":"2016-01-10T05:26:56Z","closed_at":null,"body":"I've run into this a bundle of times now and usually just force myself back to using classic module resolution, and looking into the code briefly yields no reason this should be happening.\r\n\r\nBasically, I have a lot of modules like [popsicle](https://github.com/blakeembrey/popsicle) which **does not** specify a `typings` field in `package.json`. However, once I install it using [typings](https://github.com/typings/typings) (which is just wrapping everything up into ambient module declarations) and use it, it starts to resolve the actual files even though the ambient definitions are already provided. I can only assume that there's some sort of declaration file merging doing on when using node module resolution, but some clarification would be good.\r\n\r\nHere's a snippet of the generated definition:\r\n\r\n```ts\r\n// Compiled using typings@0.5.2\r\n// Source: node_modules/popsicle/dist/form.d.ts\r\ndeclare module 'popsicle/dist/form' {\r\nimport FormData = require('popsicle~form-data');\r\nexport default function form(obj: any): FormData;\r\n}\r\n```\r\n\r\nNotice that the file is being correctly rewritten. However, with `node` resolution enabled, it'll also load the original file too - even though nothing at all references it. This results in the original code generating compiler errors and having to switch back to classic.\r\n\r\n```\r\nnode_modules/popsicle/dist/form.d.ts(1,27): error TS2307: Cannot find module 'form-data'.\r\nnode_modules/popsicle/dist/jar.d.ts(1,27): error TS2307: Cannot find module 'tough-cookie'.\r\n```\r\n\r\nI can create a replicated repo, if needed, but I hope the issue sheds enough light on the problem."},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/170316084","html_url":"https://github.com/Microsoft/TypeScript/issues/6427#issuecomment-170316084","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/6427","id":170316084,"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},"created_at":"2016-01-10T05:26:56Z","updated_at":"2016-01-10T05:26:56Z","body":"imports wont be broken since real module `react/addons` in your `d.ts` file will be represented by two ambient modules\r\n```ts\r\nmodule \"~~~react/addons\" {\r\n    // used by imports inside this .d.ts file\r\n}\r\n\r\nmodule \"react/addons\" {\r\n    // used by user code, reexports everything from \"~~~react/addons\"\r\n    export * from \"~~~react/addons\";\r\n}\r\n```\r\n\r\nin user code `require(\"react/addons\")` will be resolved to the second part so everything should work"}}