{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/7147","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/7147/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/7147/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/7147/events","html_url":"https://github.com/Microsoft/TypeScript/pull/7147","id":134770883,"number":7147,"title":"Fix ES6 imports of CommonJs modules","user":{"login":"billti","id":993909,"avatar_url":"https://avatars.githubusercontent.com/u/993909?v=3","gravatar_id":"","url":"https://api.github.com/users/billti","html_url":"https://github.com/billti","followers_url":"https://api.github.com/users/billti/followers","following_url":"https://api.github.com/users/billti/following{/other_user}","gists_url":"https://api.github.com/users/billti/gists{/gist_id}","starred_url":"https://api.github.com/users/billti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/billti/subscriptions","organizations_url":"https://api.github.com/users/billti/orgs","repos_url":"https://api.github.com/users/billti/repos","events_url":"https://api.github.com/users/billti/events{/privacy}","received_events_url":"https://api.github.com/users/billti/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/cla-not-required","name":"cla-not-required","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-19T04:43:02Z","updated_at":"2016-02-19T08:19:44Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Microsoft/TypeScript/pulls/7147","html_url":"https://github.com/Microsoft/TypeScript/pull/7147","diff_url":"https://github.com/Microsoft/TypeScript/pull/7147.diff","patch_url":"https://github.com/Microsoft/TypeScript/pull/7147.patch"},"body":"Changes to address issue #7076.  This is not yet done, but wanted to get feedback on the approach before continuing further from @vladima, @mhegazy, and/or @RyanCavanaugh .\r\n\r\nEssentially the way the `export=` symbol for `module.exports = ...` in CommonJS files was being created was quite different to the `export=` in TypeScript, even though the same symbol in `sourceFile.symbol.exports` is used for both. This was not a problem for `require(..)` calls, where the type checking of the `require` call expression was special cased. However for imports using ES2015 syntax, this was failing as it expects that a) The `export=` symbol is an alias, and b) It is an alias to a module or an identifier.\r\n\r\nThis code starts to address some of this, but a few questions remain.\r\n\r\n - I've hacked in special handling for `module.export =` where it's an object literal or an identifier. This may well be the wrong approach, and perhaps should just synthesize a symbol/type for the expression being assigned. For example, `module.exports = getSomeObj()` is perfectly valid.\r\n - ES2015 imports have different semantics/restrictions, so should we honor those (i.e. the imported alias can't have call/construct signatures - which we'd have to remove).\r\n\r\nNote that I've built this branch on top of the \"load JS from node_modules\" work, as there was some tests there that covered this (it was doing that work I undercovered this issue). It's really only the last commit ( bf030a2 ) which is of interest for this fix.\r\n\r\nLet's discuss tomorrow on the right approach before I spend more time on this..."},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/186114089","html_url":"https://github.com/Microsoft/TypeScript/pull/7147#issuecomment-186114089","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/7147","id":186114089,"user":{"login":"DanielRosenwasser","id":972891,"avatar_url":"https://avatars.githubusercontent.com/u/972891?v=3","gravatar_id":"","url":"https://api.github.com/users/DanielRosenwasser","html_url":"https://github.com/DanielRosenwasser","followers_url":"https://api.github.com/users/DanielRosenwasser/followers","following_url":"https://api.github.com/users/DanielRosenwasser/following{/other_user}","gists_url":"https://api.github.com/users/DanielRosenwasser/gists{/gist_id}","starred_url":"https://api.github.com/users/DanielRosenwasser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanielRosenwasser/subscriptions","organizations_url":"https://api.github.com/users/DanielRosenwasser/orgs","repos_url":"https://api.github.com/users/DanielRosenwasser/repos","events_url":"https://api.github.com/users/DanielRosenwasser/events{/privacy}","received_events_url":"https://api.github.com/users/DanielRosenwasser/received_events","type":"User","site_admin":false},"created_at":"2016-02-19T08:19:43Z","updated_at":"2016-02-19T08:19:43Z","body":"> Note that I've built this branch on top of the \"load JS from node_modules\" work, as there was some tests there that covered this\r\n\r\nYou can interactively rebase the branch and filter out the irrelevant commits to fix this up."}}