jsmreese / moment-duration-format

Format function plugin for the Moment Duration object.
MIT License
968 stars 120 forks source link

Add Typescript definition #58

Closed ducksoupdev closed 6 years ago

ducksoupdev commented 7 years ago

I have added a Typescript definition file as I am increasingly using this module in Typescript projects and having a definition means editors provide context help on the duration extension method.

jsmreese commented 6 years ago

I'm happy to add a Typescript definition file... your file declares format(format: string): string;, which is just one of the possible signatures for calling format.

How would you declare the possible variants of duration.format([template] [, precision] [, settings])? And how do you declare types on the settings object?

jsmreese commented 6 years ago

Ahh, something like this: https://github.com/moment/moment/blob/develop/moment.d.ts And this is for Moment Duration Format version 1.3: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/moment-duration-format/index.d.ts

jsmreese commented 6 years ago

I'm going to go ahead and close this PR.

If anyone is interesting in creating a complete typescript definition for the version 2 plugin, a PR would be welcome. Otherwise, hopefully I'll have some time to work on it in the next few weeks.

ux-engineer commented 3 years ago

@jsmreese what is the current state of TypeScript support? Readme states that type definitions were aimed for v2 release.