Title: Compiler elides import of identifier that is referenced in emitted code. · Issue #6003 · microsoft/TypeScript · GitHub
Open Graph Title: Compiler elides import of identifier that is referenced in emitted code. · Issue #6003 · microsoft/TypeScript
X Title: Compiler elides import of identifier that is referenced in emitted code. · Issue #6003 · microsoft/TypeScript
Description: // file: foo.ts import BluebirdPromise from 'bluebird'; export async function foo(): BluebirdPromise { } // file: foo.js function foo() { return __awaiter(this, void 0, BluebirdPromise, function* () { }); } exports.foo = foo; (Compiled w...
Open Graph Description: // file: foo.ts import BluebirdPromise from 'bluebird'; export async function foo(): BluebirdPromise { } // file: foo.js function foo() { return __awaiter(this, void 0, BluebirdPromise, function* (...
X Description: // file: foo.ts import BluebirdPromise from 'bluebird'; export async function foo(): BluebirdPromise { } // file: foo.js function foo() { return __awaiter(this, void 0, BluebirdPromise, fun...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/6003
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Compiler elides import of identifier that is referenced in emitted code. ","articleBody":"``` typescript\n// file: foo.ts\nimport BluebirdPromise from 'bluebird';\nexport async function foo(): BluebirdPromise { }\n\n// file: foo.js\nfunction foo() {\n return __awaiter(this, void 0, BluebirdPromise, function* () { });\n}\nexports.foo = foo;\n```\n\n(Compiled with `target=ES6, module=commonjs, noEmitHelpers=true`).\n\nThe `BluebirdPromise` import has been elided in the generated code, resulting in `\"ReferenceError: BluebirdPromise is not defined\"` at runtime.\n\nThe elision occurs because `BluebirdPromise` only appears in a type position which up until v1.7 meant that the compiler could safely elide it. But the compiler now emits this type annotation into the JavaScript output so that elision assumption is no longer safe.\n\nIMO the problem here is not the elision logic, its the fact that the compiler now emits code that depends on type annotaitons, so the type system no longer enjoys the quality of being fully erasable, which I understood to be a core [design principle](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals#goals) of the language. I thought the idea of using type annotations to change runtime behaviour would have been smacked down by @ahejlsberg and the team before it got into production.\n\nRegardless of that contended side-topic, I believe this is a bug.\n","author":{"url":"https://github.com/yortus","@type":"Person","name":"yortus"},"datePublished":"2015-12-09T01:24:09Z","url":"https://github.com/microsoft/TypeScript/issues/6003"}
| 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:b958a4d9-f248-9692-69e9-bc72be6e0c50 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D99A:1D8AA1:5FC2AF:80BD97:6B00D086 |
| html-safe-nonce | 46d5c780a07d6d8dc82ab5a4de2cf63108f704ee27686bc63c3b19af961354f4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOTlBOjFEOEFBMTo1RkMyQUY6ODBCRDk3OjZCMDBEMDg2IiwidmlzaXRvcl9pZCI6Ijg4Mjk2MzI2NTU1NDU5MTM0NzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d32617fac5cfa30a134fb8c6c1749122a5d3ae0239ef32c0392be73e93c6264a |
| hovercard-subject-tag | issue:121139700 |
| 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/6003/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b88820af0c99ed593839fabebf5ca680191f47b4b42cdae0190615bebc240c9a/microsoft/TypeScript/issues/6003 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b88820af0c99ed593839fabebf5ca680191f47b4b42cdae0190615bebc240c9a/microsoft/TypeScript/issues/6003 |
| og:image:alt | // file: foo.ts import BluebirdPromise from 'bluebird'; export async function foo(): BluebirdPromise { } // file: foo.js function foo() { return __awaiter(this, void 0, BluebirdPromise, function* (... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | yortus |
| hostname | github.com |
| expected-hostname | github.com |
| None | 85bbdfe2b6ba16e234513bc6ceff5d848ef8449820c900692a2b4e67061931e5 |
| 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 | 4943239a6d2c591325dad6e5c313e1cafda877f6 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width