I just want to add a function to the prototype interface Moment
, which will always format the same every time I use it. I have already tried what can be found here.
declare module moment {
export interface Moment {
myFormat: () => string;
}
}
And in another file implementation:
Moment.prototype.myFormat = ():string => { return this.format("DD.MM.YYY"); }
However, this does not work. I just want to be able to call moment(aDate).myFormat()
, but I can't get it to work.
Already tried to use declare module "moment"
some options moment.Moment
, but still the same.
As indicated in the link, no declare
. But then I get an error
'declare' required for a top-level item.
source
share