Title: Type annotation for all exports in the module · Issue #38511 · microsoft/TypeScript · GitHub
Open Graph Title: Type annotation for all exports in the module · Issue #38511 · microsoft/TypeScript
X Title: Type annotation for all exports in the module · Issue #38511 · microsoft/TypeScript
Description: Search Terms Export, typed exports, modules, Next.js, Redwood.js Suggestion Allow a new syntax From issue #420 that will allow typing all of exports in a module. export implements { default: string foo: (bar: boolean) => number } export ...
Open Graph Description: Search Terms Export, typed exports, modules, Next.js, Redwood.js Suggestion Allow a new syntax From issue #420 that will allow typing all of exports in a module. export implements { default: string...
X Description: Search Terms Export, typed exports, modules, Next.js, Redwood.js Suggestion Allow a new syntax From issue #420 that will allow typing all of exports in a module. export implements { default: string...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/38511
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Type annotation for all exports in the module","articleBody":"## Search Terms\r\nExport, typed exports, modules, Next.js, Redwood.js \r\n\r\n## Suggestion\r\nAllow a new syntax [From issue #420](https://github.com/microsoft/TypeScript/issues/420#issuecomment-52346304) that will allow typing all of exports in a module.\r\n\r\n```ts\r\nexport implements {\r\n default: string\r\n foo: (bar: boolean) => number\r\n}\r\n\r\nexport default \"Hello world!\";\r\nexport function foo(bar) { return 1 }\r\n```\r\n\u003c!-- removing to remove noise\r\n### Sharing \"module types\"\r\nIt should be possible to import module types\r\n\r\n```ts\r\nimport ModuleType from './module.ts';\r\n\r\ntype export = ModuleType;\r\n```\r\n\r\n### Alternative syntaxes \r\n\r\n```\r\ntype export = {}\r\n```\r\n\r\n```ts\r\nmodule type = {}\r\n```\r\n\r\n```ts\r\nexport module {}\r\n```\r\n\r\n-->\r\n\r\n\u003c!-- A summary of what you'd like to see added or changed -->\r\n\r\n## Use Cases and Examples\r\nIncreasingly frameworks are using named module exports as a way of organizing their code. For instance [Next.js](https://nextjs.org/docs/basic-features/data-fetching) is using named exports to specify things like exported component and functions for fetching data:\r\n\r\n```ts\r\nimport { PageModule } from 'next'\r\n\r\ntype Post = { title: string };\r\nexport implements PageModule\u003c{ posts: Posts[] }>;\r\n\r\nfunction Blog({ posts }) {\r\n return (\r\n \u003cul>\r\n {posts.map(post => (\r\n \u003cli>{post.title}\u003c/li>\r\n ))}\r\n \u003c/ul>\r\n )\r\n}\r\n\r\nexport async function getStaticProps() {\r\n return { props: { posts: [] } }\r\n}\r\n\r\nexport default Blog\r\n```\r\n\r\n### Frameworks relying on named export \r\n\r\n* [Next.js](https://nextjs.org/docs/basic-features/data-fetching)\r\n* [Redwood.js](https://redwoodjs.com/tutorial/side-quest-how-redwood-works-with-data)\r\n* [Remix.js](https://blog.remix.run/p/remix-preview)\r\n* [SevlteKit](https://kit.svelte.dev/)\r\n* [StroryBook](https://storybook.js.org/blog/component-story-format/)\r\n* [CloudFlare Workers](https://github.com/cloudflare/workers-types)\r\n* > please suggest more \r\n\r\n\u003c!-- Show how this would be used and what the behavior would be -->\r\n\r\n## Checklist\r\n\r\nMy suggestion meets these guidelines:\r\n\r\n* [x] This wouldn't be a breaking change in existing TypeScript/JavaScript code\r\n* [x] This wouldn't change the runtime behavior of existing JavaScript code\r\n* [x] This could be implemented without emitting different JS based on the types of the expressions\r\n* [x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)\r\n* [x] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals).\r\n\r\n\r\n### Related issues\r\n* https://github.com/microsoft/TypeScript/issues/420\r\n* https://github.com/microsoft/TypeScript/issues/13626","author":{"url":"https://github.com/mohsen1","@type":"Person","name":"mohsen1"},"datePublished":"2020-05-12T20:38:36Z","url":"https://github.com/microsoft/TypeScript/issues/38511"}
| 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:9c1c6b0a-1d06-43ae-64d5-26f2c04fad4b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D938:157C65:1EC4F87:290E2E4:6B017849 |
| html-safe-nonce | 2ac093b59c0de80d13cbcbe71e000dde6b586990708fc2ff5f72b883adf70c07 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOTM4OjE1N0M2NToxRUM0Rjg3OjI5MEUyRTQ6NkIwMTc4NDkiLCJ2aXNpdG9yX2lkIjoiODAyODA1NjI5MDU0ODg3MzI4OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 6a096cb27fb9d95c5185c6a08ec86723013726c5334a9aff316cc0d87285ff26 |
| hovercard-subject-tag | issue:616944349 |
| 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/38511/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d6c8f95f98d0e48ffee66f4bebd343771a5388e8da88e081cce6a0938fa5a3ba/microsoft/TypeScript/issues/38511 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d6c8f95f98d0e48ffee66f4bebd343771a5388e8da88e081cce6a0938fa5a3ba/microsoft/TypeScript/issues/38511 |
| og:image:alt | Search Terms Export, typed exports, modules, Next.js, Redwood.js Suggestion Allow a new syntax From issue #420 that will allow typing all of exports in a module. export implements { default: string... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mohsen1 |
| 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