jkroso / parse-duration

convert a human readable duration to ms
MIT License
243 stars 37 forks source link

TypeScript definition #12

Closed patarapolw closed 4 years ago

patarapolw commented 4 years ago

According to https://www.typescriptlang.org/docs/handbook/declaration-files/templates/module-function-d-ts.html, this is as simple as

// ./index.d.ts

export = parse

/**
 * convert `str` to ms
 */
function parse (str: string): number

And, add "typings": "index.d.ts", in your package.json. Then, upload to NPM.

Might create a Pull Request later. Hope this package will be actively maintained.

Anyways, for anyone reading this, you can also create declaration.d.ts with

declare module 'parse-duration' {
  export = parse

  /**
   * convert `str` to ms
   */
  function parse (str: string): number
}
rikkegammelmark commented 4 years ago

Any news on this? It would be great to be able to use this with typescript.

dy commented 4 years ago

Fixed