{"action":"opened","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/21620","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/21620/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/21620/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/21620/events","html_url":"https://github.com/Microsoft/TypeScript/issues/21620","id":294208703,"number":21620,"title":"Regression: Incorrect emit of when adding async function to const export in JS file","user":{"login":"bsouthga","id":4740806,"avatar_url":"https://avatars3.githubusercontent.com/u/4740806?v=4","gravatar_id":"","url":"https://api.github.com/users/bsouthga","html_url":"https://github.com/bsouthga","followers_url":"https://api.github.com/users/bsouthga/followers","following_url":"https://api.github.com/users/bsouthga/following{/other_user}","gists_url":"https://api.github.com/users/bsouthga/gists{/gist_id}","starred_url":"https://api.github.com/users/bsouthga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bsouthga/subscriptions","organizations_url":"https://api.github.com/users/bsouthga/orgs","repos_url":"https://api.github.com/users/bsouthga/repos","events_url":"https://api.github.com/users/bsouthga/events{/privacy}","received_events_url":"https://api.github.com/users/bsouthga/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-02-04T16:14:33Z","updated_at":"2018-02-04T16:14:33Z","closed_at":null,"author_association":"NONE","body":"<!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨 -->\r\n<!--\r\nHalf of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker.\r\n\r\nPlease help us by doing the following steps before logging an issue:\r\n  * Search: https://github.com/Microsoft/TypeScript/search?type=Issues\r\n  * Read the CONTRIBUTING guidelines: https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md\r\n  * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ\r\n-->\r\n\r\n<!-- If you have a QUESTION:\r\n   THIS IS NOT A FORUM FOR QUESTIONS.\r\n   Ask questions at http://stackoverflow.com/questions/tagged/typescript\r\n    or https://gitter.im/Microsoft/TypeScript\r\n-->\r\n\r\n<!-- If you have a SUGGESTION:\r\n  Most suggestion reports are duplicates, please search extra hard before logging a new suggestion.\r\n  See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md\r\n-->\r\n\r\n<!-- If you have a BUG:\r\n  Please fill in the *entire* template below.\r\n-->\r\n\r\nThe following occurs in `2.7.1` and `next`, but does not occur in `2.6.2` (emit is correct, no runtime error).\r\n\r\n<!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->\r\n**TypeScript Version:**  2.7.1\r\n\r\n<!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:** \r\nexport, emit, es2017, class\r\n\r\n**Code**\r\n\r\n```ts\r\n// this is a javacript file...\r\n\r\nexport const Adapter = {};\r\n\r\nAdapter.prop = {};\r\n\r\n// comment this out, and it works\r\nAdapter.asyncMethod = async function() {}\r\n```\r\n\r\n`tsconfig.json`:\r\n\r\n```\r\n{\r\n  \"compilerOptions\": {\r\n    \"target\": \"es2017\",\r\n    \"module\": \"commonjs\",\r\n    \"strict\": true,\r\n    \"sourceMap\": true,\r\n    \"allowJs\": true,\r\n    \"outDir\": \"dist\",\r\n    \"noLib\": false,\r\n    \"skipLibCheck\": true,\r\n    \"strictFunctionTypes\": false,\r\n    \"lib\": [\"es2017\"],\r\n  }\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\n\r\nCode compiles and runs successfully, the emit should look like...\r\n\r\n```\r\n\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.Adapter = {};\r\nexports.Adapter.prop = {};\r\n// comment this out, and it works\r\nexports.Adapter.asyncMethod = async function () { };\r\n//# sourceMappingURL=test.js.map\r\n```\r\n\r\n**Actual behavior:**\r\n\r\nThe following gets emitted: \r\n\r\n```\r\n\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.Adapter = {};\r\nAdapter.prop = {};\r\n// comment this out, and it works\r\nAdapter.asyncMethod = async function () { };\r\n//# sourceMappingURL=test.js.map\r\n```\r\n\r\nwhich causes a runtime error as `Adapter` is not defined.\r\n\r\n**Playground Link:** \r\n\r\nCan't configure playground to the same setup, so here is a link to self contained repo: https://github.com/bsouthga/typescript-js-const-export-bug\r\n"}}
{"actor":{"display_login":"bsouthga"}}