Title: Re-exports of external modules with side effects are erased from ES5 targets · Issue #6835 · microsoft/TypeScript · GitHub
Open Graph Title: Re-exports of external modules with side effects are erased from ES5 targets · Issue #6835 · microsoft/TypeScript
X Title: Re-exports of external modules with side effects are erased from ES5 targets · Issue #6835 · microsoft/TypeScript
Description: Re-exports of external modules with no public members are erased from the generated JS for ES5 targets. This causes problems in scenarios where the module is used to extend some class by patching the prototype (see #6213 and #6022). The ...
Open Graph Description: Re-exports of external modules with no public members are erased from the generated JS for ES5 targets. This causes problems in scenarios where the module is used to extend some class by patching t...
X Description: Re-exports of external modules with no public members are erased from the generated JS for ES5 targets. This causes problems in scenarios where the module is used to extend some class by patching t...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/6835
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Re-exports of external modules with side effects are erased from ES5 targets","articleBody":"Re-exports of external modules with no public members are erased from the generated JS for ES5 targets. This causes problems in scenarios where the module is used to extend some class by patching the prototype (see #6213 and #6022).\n\nThe ultimate goal is to be able to do the following:\n\n```\n// a.ts\nexport class A { }\n```\n\n```\n// b.ts\nimport {A} from './a';\nA.prototype.foo = function () { };\ndeclare module './a' {\n interface A { foo(): void; }\n}\n```\n\n```\n// c.ts\nimport {A} from './a';\nA.prototype.bar = function () { };\ndeclare module './a' {\n interface A { bar(): void; }\n}\n```\n\n```\n// all.ts\nexport {A} from './a';\nexport * from './b';\nexport * from './c';\n```\n\nOnce this is built and distributed as a set of JS and definition files, the user should be able to do:\n\n```\nimport {A} from 'somemodule/a';\nimport 'somemodule/all';\n\nvar a = new A();\na.foo();\na.bar();\n```\n\nCurrently, this compiles without errors, but produces the following output for `all.js`:\n\n```\n\"use strict\";\nvar a_1 = require('./a');\nexports.A = a_1.A;\n```\n\nYou can see that `./b` and `./c` are not imported, which results in the prototype patches for `A` being unavailable at runtime. The user will therefore get the following exception:\n\n> TypeError: a.foo is not a function\n\nHopefully I'm not misusing the feature here.\n","author":{"url":"https://github.com/masaeedu","@type":"Person","name":"masaeedu"},"datePublished":"2016-02-02T11:16:47Z","url":"https://github.com/microsoft/TypeScript/issues/6835"}
| 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:e5bdc7c7-6583-5a93-d572-49abfe14fb48 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A0BC:237673:D31586:11B22D0:6B01019C |
| html-safe-nonce | e58553171f5a3842c3cd723c26cce7d6650178204cea8a8a25fb967da9e22570 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMEJDOjIzNzY3MzpEMzE1ODY6MTFCMjJEMDo2QjAxMDE5QyIsInZpc2l0b3JfaWQiOiIyMTQxMzkzNzUxMjQxNzIwMjIwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | dfe5d1d75b57f757aeadcfe985e1b37c63e25fc9489e1b6118dfb16591658018 |
| hovercard-subject-tag | issue:130651909 |
| 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/6835/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7faf8285597d3a9c2cd76c4aae34218de0dcdb997cad3062c692ec017a56a62b/microsoft/TypeScript/issues/6835 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7faf8285597d3a9c2cd76c4aae34218de0dcdb997cad3062c692ec017a56a62b/microsoft/TypeScript/issues/6835 |
| og:image:alt | Re-exports of external modules with no public members are erased from the generated JS for ES5 targets. This causes problems in scenarios where the module is used to extend some class by patching t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | masaeedu |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| 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 | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width