I added moment-timezone to the moment definition for a project I'm working on. I would assume moment is most often used without timezone, which makes the current definition more useful to most people. Just thought I'ld leave the timezone definition here in case it helps someone out. This is the gist of the resulting file. Thanks for the work on the moment definition.
Is there an action item here?
moment-timezone patches the object returned by require('moment') to include timezone methods, but it also exports that object itself.
I don't know if flow has a means to model monkey-patched libraries, but that's probably not even necessary here. The action item might be a moment-timezone libdef that extends the moment libdef. Then clients should import moment from 'moment-timezone' instead of from 'moment'.
Something like..
import type moment from 'moment';
interface moment$Timezone extends moment {
parsingFlags(): {[key:string] : any};
static tz: moment$Timezone;
tz(tz:string):moment$Moment;
tz():string;
zoneAbbr():string;
zoneName():string;
}
declare class moment$Timezone { ... }
type moment$ZoneObject = { ... }
declare class moment$MomentDuration { ... }
declare class moment$LocaleData { ... }
type moment$CalendarFormats = { ... }
type moment$MomentCreationData = { ... }
type moment$MomentObject = { ... }
type moment$MomentOptions = { ... }
declare module 'moment-timezone' {
declare module.exports: Class<moment$timezone>;
}
We switched to moment-timezone from moment and I ran into this just now too. Anything preventing this from being added to the repo? Should I make a PR?
Most helpful comment
We switched to
moment-timezonefrommomentand I ran into this just now too. Anything preventing this from being added to the repo? Should I make a PR?