You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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) {
moment = _moment['default'];
}
....
At 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.
As 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().
I would appreciate it if someone could shed some light on whether I'm doing something wrong or it's a bug.
Thanks!
The text was updated successfully, but these errors were encountered:
I'm using TS 1.6.3 and JSPM. I
jspm install
-ed moment and then import it like soimport * as moment from 'moment'
This compiles to
Using Babel this compiles to
At runtime the
moment_1
or_moment
variable refers to an object which actually has adefault
property which is the MomentJS's factory. So, to me, it looks like Babel is correct.As 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 asmoment
will be an object, not a function. You also can't domoment.default()
because in thed.ts
file there is nodefault
function. At the moment I'm doing a hack(moment as any).default()
.I would appreciate it if someone could shed some light on whether I'm doing something wrong or it's a bug.
Thanks!
The text was updated successfully, but these errors were encountered: