Title: Improve readability of default exports · Issue #7407 · microsoft/TypeScript · GitHub
Open Graph Title: Improve readability of default exports · Issue #7407 · microsoft/TypeScript
X Title: Improve readability of default exports · Issue #7407 · microsoft/TypeScript
Description: I'm unable to export default modules/namespaces like this: export default namespace Utils { // throws error TS1005: ';' expected ... Not sure if its related to #3792, but that isn't actually my issue... Since I can't export default the n...
Open Graph Description: I'm unable to export default modules/namespaces like this: export default namespace Utils { // throws error TS1005: ';' expected ... Not sure if its related to #3792, but that isn't actually my iss...
X Description: I'm unable to export default modules/namespaces like this: export default namespace Utils { // throws error TS1005: ';' expected ... Not sure if its related to #3792, but that isn't...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/7407
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Improve readability of default exports","articleBody":"I'm unable to `export default` modules/namespaces like this:\n\n``` ts\nexport default namespace Utils { // throws error TS1005: ';' expected\n...\n```\n\nNot sure if its related to #3792, but that isn't actually my issue...\nSince I can't `export default` the namespace directly, I would like to convention that default exports should be placed in a separate statement and always put in the first lines of the file:\n\n``` ts\nexport default Utils\n\nimport * as Foo from \"foo\"\n// ...\nimport {Bar, Baz} from \"bar\"\n\nlet fooIt = Foo.Factory.SpecialFoo.Create\n// ...\n\nnamespace Utils {\n // ...\n}\n```\n\nIMO it would improve readability and make it easier to understand how to consume that file/module.\n\nDespite the fact that the compiler seems to understand that I'm exporting the `Utils` namespace, the transpiled code does not associate the export statement and my internal module, [causing the default export to be undefined at run time](http://www.typescriptlang.org/Playground#src=%2F%2F%20'var%20Utils'%20could%20be%20transpiled%20over%20here%0Aexport%20default%20Utils%20%0A%0Anamespace%20Utils%20%7B%0A%20%20export%20function%20test%28%29%20%7B%0A%09%20%20console.log%28'TEST'%29%0A%20%20%7D%0A%7D).\n\nWould be nice to get `export default` transpiled to the of the file or declare the module container earlier, so I can export it wherever I want. \n\nIf #3792 gets fixed I can just convention that the default module should always come first, and keep my default export always on sight. So this is issue is more like a suggestion I suppose...\n\n\u003csub>Typescript Version 1.9.0-dev.20160220\u003c/sub>\n","author":{"url":"https://github.com/bykbtzr","@type":"Person","name":"bykbtzr"},"datePublished":"2016-03-06T02:43:26Z","url":"https://github.com/microsoft/TypeScript/issues/7407"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:46df4a5c-1e31-48e3-43c6-ac7c9e9aa9a7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C04C:3C028F:26B72:32F88:6B015AB7 |
| html-safe-nonce | aa82e3395b3d04748c61059f7534a38d41f6dc2fb738e4c007ee15d8cc4f31dc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMDRDOjNDMDI4RjoyNkI3MjozMkY4ODo2QjAxNUFCNyIsInZpc2l0b3JfaWQiOiIzNjY4MjA3NTk1MDc3ODUxODMxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 4319e670e7f4ea4d8cf706a3cae5123102f6a9e9647b774ab51def7043b3f0da |
| hovercard-subject-tag | issue:138745973 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/7407/issue_layout |
| twitter:image | https://opengraph.githubassets.com/108241209f2c5b362d489bc379bcf3bb1e1a92d2733ee15bdd82ee84a6ee37bd/microsoft/TypeScript/issues/7407 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/108241209f2c5b362d489bc379bcf3bb1e1a92d2733ee15bdd82ee84a6ee37bd/microsoft/TypeScript/issues/7407 |
| og:image:alt | I'm unable to export default modules/namespaces like this: export default namespace Utils { // throws error TS1005: ';' expected ... Not sure if its related to #3792, but that isn't actually my iss... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bykbtzr |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width