-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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) {
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!