Title: Transpilation of ES6 imports is inconsistent with babel · Issue #5458 · microsoft/TypeScript · GitHub
Open Graph Title: Transpilation of ES6 imports is inconsistent with babel · Issue #5458 · microsoft/TypeScript
X Title: Transpilation of ES6 imports is inconsistent with babel · Issue #5458 · microsoft/TypeScript
Description: Currently, babel and typescript handle transpilation of ES6 imports differently. The following works in typescript: import * as rp from 'request-promise'; rp('http://github.com').then(console.log); but I get an error when running it with...
Open Graph Description: Currently, babel and typescript handle transpilation of ES6 imports differently. The following works in typescript: import * as rp from 'request-promise'; rp('http://github.com').then(console.log);...
X Description: Currently, babel and typescript handle transpilation of ES6 imports differently. The following works in typescript: import * as rp from 'request-promise'; rp('http://github.com').th...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/5458
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Transpilation of ES6 imports is inconsistent with babel","articleBody":"Currently, babel and typescript handle transpilation of ES6 imports differently.\n\nThe following works in typescript:\n\n``` typescript\nimport * as rp from 'request-promise';\n\nrp('http://github.com').then(console.log);\n```\n\nbut I get an error when running it with babel's transpilation:\n\n```\nTypeError: object is not a function\n at Object.\u003canonymous> (./test.js:7:1)\n at Module._compile (module.js:456:26)\n at Object.Module._extensions..js (module.js:474:10)\n at Module.load (module.js:356:32)\n at Function.Module._load (module.js:312:12)\n at Function.Module.runMain (module.js:497:10)\n at startup (node.js:119:16)\n at node.js:906:3\n```\n\nTo get it to work with babel, I have to do the following: \n\n``` typescript\nimport rp from 'request-promise';\n```\n\nbut that returns an error when compiling with typescript:\n\n```\ntest.ts(1,8): error TS1192: Module ''request-promise'' has no default export.\n```\n\nI currently have a pipeline of `typescript --tsc--> es6 --babel--> es5` so that I can use `async/await` while I wait for TypeScript to support it for ES5. However, that means I have to modify all my DefinitelyTyped declarations to have a default export so that `tsc` doesn't complain.\n\nDiscussions of which standard is better for transpilation put aside, my feeling is that TypeScript should follow the standard set by babel rather than using their own since babel is further along at supporting es6, and has a larger community at this point:\n\nnpm babel\n\n```\n33,936 downloads in the last day\n174,998 downloads in the last week\n551,455 downloads in the last month\n```\n\nnpm typescript\n\n```\n15,303 downloads in the last day\n101,148 downloads in the last week\n357,086 downloads in the last month\n```\n\nIn addition to keeping in step with the larger community, it would help adoption of typescript by making the transition to typescript from babel more seamless.\n","author":{"url":"https://github.com/eggers","@type":"Person","name":"eggers"},"datePublished":"2015-10-29T21:39:47Z","url":"https://github.com/microsoft/TypeScript/issues/5458"}
| 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:6e3585f9-4e0a-4c7d-9d4f-a822888ab3f7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9ED2:1148D3:1542DFA:1B2BB03:6B0132DE |
| html-safe-nonce | 7804ffc3f115e2162c70160d7c52e705fe378015a8ec8907cb8b89ac9afca167 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RUQyOjExNDhEMzoxNTQyREZBOjFCMkJCMDM6NkIwMTMyREUiLCJ2aXNpdG9yX2lkIjoiNTk4MTk4OTM1NzQxNjk1MjU0MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | fc6d4a90f7999c082035e53701e8ddfa9a10cd895ad999445d8e5d6ed4a4e921 |
| hovercard-subject-tag | issue:114153647 |
| 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/5458/issue_layout |
| twitter:image | https://opengraph.githubassets.com/97b5296c3b1ab90cabdd70a0df6eb0c216c9204ef9030d49c42a5dda69cd3138/microsoft/TypeScript/issues/5458 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/97b5296c3b1ab90cabdd70a0df6eb0c216c9204ef9030d49c42a5dda69cd3138/microsoft/TypeScript/issues/5458 |
| og:image:alt | Currently, babel and typescript handle transpilation of ES6 imports differently. The following works in typescript: import * as rp from 'request-promise'; rp('http://github.com').then(console.log);... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | eggers |
| 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