I'm trying to use momentJs from typescript: depending on what module system I'm using to compile typescript, I find a different behaviour on how I can use momentJs. When compiling typescript with commonJs everything works as expected and I can just follow momentJs documentation:
import moment = require("moment");
moment(new Date()); //this works
If I use "system" as typescript module system when I import "moment" I am forced to do
import moment = require("moment");
moment.default(new Date()); //this works
moment(new Date()); //this doesn't work
I found a workaround to make them both work regardless of typescript module system used
import m = require("moment")
var moment : moment.MomentStatic;
moment = (m as any).default || m;
I don't like this, and I would like to understand why it behaves like this. Am I doing something wrong? Can anybody explain me what's happening?