Title: Type-directed emit breaks language design goals. Is it worth it? · Issue #6007 · microsoft/TypeScript · GitHub
Open Graph Title: Type-directed emit breaks language design goals. Is it worth it? · Issue #6007 · microsoft/TypeScript
X Title: Type-directed emit breaks language design goals. Is it worth it? · Issue #6007 · microsoft/TypeScript
Description: Project A: // file: foo-a.ts import BluebirdPromise = require('bluebird'); export async function foo(): BluebirdPromise { } // <== has type annotation // file: foo-a.js function foo() { return __awaiter(this, void 0, BluebirdPromise, fun...
Open Graph Description: Project A: // file: foo-a.ts import BluebirdPromise = require('bluebird'); export async function foo(): BluebirdPromise { } // <== has type annotation // file: foo-a.js function foo() { return __aw...
X Description: Project A: // file: foo-a.ts import BluebirdPromise = require('bluebird'); export async function foo(): BluebirdPromise { } // <== has type annotation // file: foo-a.js function foo() { ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/6007
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Type-directed emit breaks language design goals. Is it worth it?","articleBody":"#### Project A:\n\n``` typescript\n// file: foo-a.ts\nimport BluebirdPromise = require('bluebird');\nexport async function foo(): BluebirdPromise { } // \u003c== has type annotation\n\n// file: foo-a.js\nfunction foo() {\n return __awaiter(this, void 0, BluebirdPromise, function* () { });\n}\nexports.foo = foo;\n\n```\n#### Project B:\n\n``` typescript\n// file: foo-b.ts\nimport BluebirdPromise = require('bluebird');\nexport async function foo() { } // \u003c== no type annotation\n\n// file: foo-b.js\nfunction foo() {\n return __awaiter(this, void 0, Promise, function* () { });\n}\nexports.foo = foo;\n```\n\nThese two projects differ only by a single type annotation, but they produce different JavaScript code with different runtime behaviour.\n\n(Compiled with v1.7.3 with `target=ES6, module=commonjs, noEmitHelpers=true`).\n\n(Note elison bug #6003 is also visible here but not the subject of this issue.)\n#### Bug or by design?\n\nI understand this is [by design](https://github.com/Microsoft/TypeScript/issues/5911#issuecomment-161736662) (sorry I can't find a better ref).\n\nHowever I strongly feel this should be considered a bug, because having a _\"fully erasable, structural type system\"_ is a core design principle of TypeScript (quote is from the [design goals page](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals#goals)).\n\nIf this is tagged as 'by design', could we please get some sort of statement from the team to clarify where TypeScript now stands on the \"fully erasable type system\" goal and the _\"[don't] emit different code based on the results of the type system\"_ non-goal?\n","author":{"url":"https://github.com/yortus","@type":"Person","name":"yortus"},"datePublished":"2015-12-09T03:30:46Z","url":"https://github.com/microsoft/TypeScript/issues/6007"}
| 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:5d77d255-b9ff-1630-2b91-6bfcd3dba0f4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CADC:91CF4:7E0A4B:A8F722:6B00DB29 |
| html-safe-nonce | 81e25f92e8d339df8d77b361359e1e37161c29804e426e7fe4e01c8b589a5285 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQURDOjkxQ0Y0OjdFMEE0QjpBOEY3MjI6NkIwMERCMjkiLCJ2aXNpdG9yX2lkIjoiNTEwMDgzNzM3MTY2Mjg4MzYyNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 9cffaaa07fbf6920963e70f168f95e51c23008fe3018c03222a95d62954a8797 |
| hovercard-subject-tag | issue:121152242 |
| 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/6007/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7652d6ae43e7d584ea49cbf481279a3e24824806fa9c4d2f02b8e52ce4213ded/microsoft/TypeScript/issues/6007 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7652d6ae43e7d584ea49cbf481279a3e24824806fa9c4d2f02b8e52ce4213ded/microsoft/TypeScript/issues/6007 |
| og:image:alt | Project A: // file: foo-a.ts import BluebirdPromise = require('bluebird'); export async function foo(): BluebirdPromise { } // <== has type annotation // file: foo-a.js function foo() { return __aw... |
| 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 | a481f62a1e04c9b9bdcb5628230682c66d59006f5b13b080f79cba84a176905b |
| 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 | 84c8c5cc25e2fb7f2308428458538436baecc6d2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width