Skip to content

Instantly share code, notes, and snippets.

@taschmidt
Created March 26, 2020 10:53
Show Gist options
  • Select an option

  • Save taschmidt/8859ab374e70c50716deae1309b3ec90 to your computer and use it in GitHub Desktop.

Select an option

Save taschmidt/8859ab374e70c50716deae1309b3ec90 to your computer and use it in GitHub Desktop.
Typescript definition for moment-msdate
import * as moment from 'moment-timezone';
// moment-msdate doesn't provide strong types, so add them here
declare module 'moment' {
export function fromOADate(oaDate: number, offset?: (string | number)): moment.Moment;
interface Moment {
toOADate(): number;
}
}
export * from 'moment-msdate';
@JavascriptMick
Copy link

embarrassed to say, I finally gave up and did this

        // @ts-ignore
        const nowMS = nowMoment.toOADate(); // this function is bootstrapped onto the moment type by moment-msdate but this lib does not export strong types so we need to tell TS to ignore it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment