Overwrite the moment. Now () in a typescript application

I have a task to sync MomentJS with server time in Angular2 application.

MomentJS has a function to change the time source as stated here

But the typescript compiler does not allow me to overwrite the moment # now () function as it is exported as a function from the namespace at moment .d.ts, so I get the error.

Cannot assign 'now' because it is a constant or read-only property.

Meanwhile moment .d.ts has a comment at the moment # now:

// ... Overwrite with profit

So I am assuming that I am something wrong.

I am using angular-cli rc4, MomentJS 2.18.1 and import as

import * as a moment from a "moment";

I appreciate your help.

+3


source to share





All Articles