Title: In JS, export assignments should bind as types, not just values · Issue #23788 · microsoft/TypeScript · GitHub
Open Graph Title: In JS, export assignments should bind as types, not just values · Issue #23788 · microsoft/TypeScript
X Title: In JS, export assignments should bind as types, not just values · Issue #23788 · microsoft/TypeScript
Description: Currently, there is special code in the checker to look up values as type in order to support the value-only way that the binder exports things that come from an export assignment, even things that in Typescript export types, such as cla...
Open Graph Description: Currently, there is special code in the checker to look up values as type in order to support the value-only way that the binder exports things that come from an export assignment, even things that...
X Description: Currently, there is special code in the checker to look up values as type in order to support the value-only way that the binder exports things that come from an export assignment, even things that...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/23788
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"In JS, export assignments should bind as types, not just values","articleBody":"Currently, there is special code in the checker to look up values as type in order to support the value-only way that the binder exports things that come from an export assignment, even things that in Typescript export types, such as classes.\r\n\r\nThe binder should instead treat JS export assignments as types if the initialiser (such as a class or constructor function) or later assignments (such as prototype assignments) warrant it. That means the checker code will be more uniform and easier to understand.\r\n\r\n**Code**\r\n\r\n```js\r\nfunction F() {\r\n}\r\nF.prototype.method = function() {\r\n}\r\nexports.F = F\r\n```\r\n\r\nAllows `F` to be used as a type:\r\n\r\n```js\r\nvar x = require('./module')\r\n/** @type {x.F} */\r\n```\r\n\r\nBut this doesn't work in pure typespace:\r\n\r\n```js\r\n/** @typedef {import('./module').F} F */\r\n/** @type {F} */\r\nvar f;\r\n```\r\n\r\nNote that binding this way will enable tricks that aren't possible in Typescript today:\r\n\r\n```js\r\nmodule.exports. C = class {\r\n}\r\nmodule.exports.C.D = class {\r\n}\r\n```\r\n\r\nNow `var m = require('./module')` makes both `m.C` and `m.C.D` available as types.","author":{"url":"https://github.com/sandersn","@type":"Person","name":"sandersn"},"datePublished":"2018-04-30T21:31:38Z","url":"https://github.com/microsoft/TypeScript/issues/23788"}
| 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:aa22d1c5-2c72-7fa5-b9f1-673fd4f4515f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C018:33444D:23E440D:2FBB8A5:6B019764 |
| html-safe-nonce | 2155b7ce1a104726e89c4390e19df09403b6b444e8c01eda9e2a458df890890f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMDE4OjMzNDQ0RDoyM0U0NDBEOjJGQkI4QTU6NkIwMTk3NjQiLCJ2aXNpdG9yX2lkIjoiNDI4Mjk3ODE5NzIzNjE5MzEyNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 436acad01b31bb78f1d87c5ecc223477283d86a7552c340a3271cb7b6a35f728 |
| hovercard-subject-tag | issue:319043089 |
| 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/23788/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f9961a3483810738fa2ff173295fb3aed9d82262aae4b7750996afd72622d497/microsoft/TypeScript/issues/23788 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f9961a3483810738fa2ff173295fb3aed9d82262aae4b7750996afd72622d497/microsoft/TypeScript/issues/23788 |
| og:image:alt | Currently, there is special code in the checker to look up values as type in order to support the value-only way that the binder exports things that come from an export assignment, even things that... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sandersn |
| 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