{"action":"closed","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/7807","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/7807/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/7807/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/7807/events","html_url":"https://github.com/Microsoft/TypeScript/issues/7807","id":145705072,"number":7807,"title":"Default export creates invalid declaration file","user":{"login":"hammy55","id":1459814,"avatar_url":"https://avatars.githubusercontent.com/u/1459814?v=3","gravatar_id":"","url":"https://api.github.com/users/hammy55","html_url":"https://github.com/hammy55","followers_url":"https://api.github.com/users/hammy55/followers","following_url":"https://api.github.com/users/hammy55/following{/other_user}","gists_url":"https://api.github.com/users/hammy55/gists{/gist_id}","starred_url":"https://api.github.com/users/hammy55/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hammy55/subscriptions","organizations_url":"https://api.github.com/users/hammy55/orgs","repos_url":"https://api.github.com/users/hammy55/repos","events_url":"https://api.github.com/users/hammy55/events{/privacy}","received_events_url":"https://api.github.com/users/hammy55/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Bug","name":"Bug","color":"e11d21"}],"state":"closed","locked":false,"assignee":{"login":"sheetalkamat","id":8052792,"avatar_url":"https://avatars.githubusercontent.com/u/8052792?v=3","gravatar_id":"","url":"https://api.github.com/users/sheetalkamat","html_url":"https://github.com/sheetalkamat","followers_url":"https://api.github.com/users/sheetalkamat/followers","following_url":"https://api.github.com/users/sheetalkamat/following{/other_user}","gists_url":"https://api.github.com/users/sheetalkamat/gists{/gist_id}","starred_url":"https://api.github.com/users/sheetalkamat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sheetalkamat/subscriptions","organizations_url":"https://api.github.com/users/sheetalkamat/orgs","repos_url":"https://api.github.com/users/sheetalkamat/repos","events_url":"https://api.github.com/users/sheetalkamat/events{/privacy}","received_events_url":"https://api.github.com/users/sheetalkamat/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/Microsoft/TypeScript/milestones/1","html_url":"https://github.com/Microsoft/TypeScript/milestones/TypeScript%202.0","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/milestones/1/labels","id":721040,"number":1,"title":"TypeScript 2.0","description":"The next major release of TypeScript","creator":{"login":"RyanCavanaugh","id":6685088,"avatar_url":"https://avatars.githubusercontent.com/u/6685088?v=3","gravatar_id":"","url":"https://api.github.com/users/RyanCavanaugh","html_url":"https://github.com/RyanCavanaugh","followers_url":"https://api.github.com/users/RyanCavanaugh/followers","following_url":"https://api.github.com/users/RyanCavanaugh/following{/other_user}","gists_url":"https://api.github.com/users/RyanCavanaugh/gists{/gist_id}","starred_url":"https://api.github.com/users/RyanCavanaugh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RyanCavanaugh/subscriptions","organizations_url":"https://api.github.com/users/RyanCavanaugh/orgs","repos_url":"https://api.github.com/users/RyanCavanaugh/repos","events_url":"https://api.github.com/users/RyanCavanaugh/events{/privacy}","received_events_url":"https://api.github.com/users/RyanCavanaugh/received_events","type":"User","site_admin":false},"open_issues":138,"closed_issues":136,"state":"open","created_at":"2014-07-14T23:24:03Z","updated_at":"2016-04-04T20:59:13Z","due_on":null,"closed_at":null},"comments":0,"created_at":"2016-04-04T14:45:14Z","updated_at":"2016-04-04T20:59:13Z","closed_at":"2016-04-04T20:59:13Z","body":"ES6 'export default _expression_' syntax creates an invalid declaration file when compiled with --outFile.\r\n\r\nCompiling the below code:\r\n```ts\r\n// pi.ts\r\nexport default 3.14159;\r\n```\r\nWith the following config:\r\n```js\r\n// tsconfig.json\r\n{\r\n    \"compilerOptions\": {\r\n        \"module\": \"system\",\r\n        \"outFile\": \"app.js\",\r\n        \"declaration\": true\r\n    },\r\n    \"files\": [\r\n        \"pi.ts\"\r\n    ]\r\n}\r\n```\r\nResults in the following invalid d.ts file:\r\n```ts\r\n// app.d.ts\r\ndeclare module \"pi\" {\r\n    // TS1038: A 'declare' modifier cannot be used in an already ambient context.\r\n    declare var _default: number;\r\n    export default _default;\r\n}\r\n```\r\n\r\nThe issue only occurs when the _expression_ is a literal or return value.\r\n\r\nThe work around in both cases is to declare a name for the default export:\r\n```ts\r\nconst PI = 3.14159;\r\nexport default PI;\r\n```\r\n\r\nTypescript Version 1.8.5"}}