safe-regex icon indicating copy to clipboard operation
safe-regex copied to clipboard

feat: add TS type declarations

Open ImRodry opened this issue 3 years ago • 1 comments

This PR adds built-in TS type definitions taken from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/safe-regex (aka npmjs.com/package/@types/safe-regex)

Note for the future and for maintainability: these types only need to be changed if:

  • A new export is added to the package (either a function, object, etc)
  • A new parameter is added to the function
  • A new option is added to the options interface

In order to update the options, simply add a new line after the existing one and type the name of the option followed by its type. You can see TS's most basic types here: https://www.w3schools.com/typescript/typescript_simple_types.php

If adding a new export that isn't the default export, simply declare it with the export keyword before it. Be sure to give it the same name it has in the code!

ImRodry avatar Nov 01 '22 15:11 ImRodry

This PR supersedes #29 as it was outdated and had merge conflicts

ImRodry avatar Nov 01 '22 15:11 ImRodry