Title: Importing momentjs using jspm · Issue #5682 · microsoft/TypeScript · GitHub
Open Graph Title: Importing momentjs using jspm · Issue #5682 · microsoft/TypeScript
X Title: Importing momentjs using jspm · Issue #5682 · microsoft/TypeScript
Description: I'm using TS 1.6.3 and JSPM. I jspm install-ed moment and then import it like so import * as moment from 'moment' This compiles to .... function(moment_1) { moment = moment_1; } .... Using Babel this compiles to .... function(_moment) { ...
Open Graph Description: I'm using TS 1.6.3 and JSPM. I jspm install-ed moment and then import it like so import * as moment from 'moment' This compiles to .... function(moment_1) { moment = moment_1; } .... Using Babel th...
X Description: I'm using TS 1.6.3 and JSPM. I jspm install-ed moment and then import it like so import * as moment from 'moment' This compiles to .... function(moment_1) { moment = moment_1; } .... Us...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/5682
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Importing momentjs using jspm","articleBody":"I'm using TS 1.6.3 and JSPM. I `jspm install`-ed moment and then import it like so\n import \\* as moment from 'moment'\n\nThis compiles to\n\n```\n....\nfunction(moment_1) {\n moment = moment_1;\n}\n....\n```\n\nUsing Babel this compiles to\n\n```\n....\nfunction(_moment) {\n moment = _moment['default'];\n}\n....\n```\n\nAt runtime the `moment_1` or `_moment` variable refers to an object which actually has a `default` property which is the MomentJS's factory. So, to me, it looks like Babel is correct. \n\nAs a result of the way the TS compiler compiles it, it's not possible, in TypeScript code, to simply do `var x = moment()` because at runtime that will fail as `moment` will be an object, not a function. You also can't do `moment.default()` because in the `d.ts` file there is no `default` function. At the moment I'm doing a hack `(moment as any).default()`.\n\nI would appreciate it if someone could shed some light on whether I'm doing something wrong or it's a bug.\n\nThanks!\n","author":{"url":"https://github.com/adrianhara","@type":"Person","name":"adrianhara"},"datePublished":"2015-11-16T12:36:08Z","url":"https://github.com/microsoft/TypeScript/issues/5682"}
| 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:91893c60-5f2a-5e22-c9d3-ab1735a90bed |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8234:363D8E:19AE0B7:20A9DDA:6B0131C7 |
| html-safe-nonce | f834aa6a257768511e499d351311dcd3a8df3936593627053bbdd212d9c144ef |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MjM0OjM2M0Q4RToxOUFFMEI3OjIwQTlEREE6NkIwMTMxQzciLCJ2aXNpdG9yX2lkIjoiNzkwMDY5MzQyOTEzNzUxOTA0NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 16e7c7ed95e6bd3d64ba66e5417e411eb5919d63e207495dc1b22b2fe1b49757 |
| hovercard-subject-tag | issue:117114353 |
| 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/5682/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1dd37cb6fbef537b6d4e8562375598f6d7fe8f754f34ef3a0c7eb612b552034b/microsoft/TypeScript/issues/5682 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1dd37cb6fbef537b6d4e8562375598f6d7fe8f754f34ef3a0c7eb612b552034b/microsoft/TypeScript/issues/5682 |
| og:image:alt | I'm using TS 1.6.3 and JSPM. I jspm install-ed moment and then import it like so import * as moment from 'moment' This compiles to .... function(moment_1) { moment = moment_1; } .... Using Babel th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | adrianhara |
| 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 | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width