Skip to content

added ts definitions #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// TypeScript Version: 3.5.2

interface Options {
limit: number;
}

declare function safeRegex<T>(regex: RegExp | string | T, options?: Options): boolean;
Copy link

@sverweij sverweij Oct 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • The union for the regex with RegExp and string is an improvement 👍
  • Could you explain how the generic (the <T> and the T in union of the first parameter) relates to the original function? The declaration without it (export function safeRegex (regex: RegExp | string | any, options?: Options): boolean) seems to match the original function just as well, but I might've missed some thing.


export = safeRegex;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.1.0",
"description": "detect possibly catastrophic, exponential-time regular expressions",
"main": "index.js",
"types": "index.d.ts",
"dependencies": {
"regexp-tree": "~0.1.1"
},
Expand Down