Skip to content

Commit

Permalink
Add TypeScript definition (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiekyle-eb authored and sindresorhus committed Jun 29, 2019
1 parent a0f071b commit 2ef1fc0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
16 changes: 16 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export interface Options {
/**
* Only match an exact string.
*
* @default false
*/
exact?: boolean
}

/**
* Returns a regex for matching email addresses.
*
* @param options - Configure the generated regular expression
* @returns Regex for matching email addresses.
*/
export default function emailRegex(options?: Options): RegExp;
8 changes: 8 additions & 0 deletions index.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {expectType} from 'tsd-check';
import emailRegex from '.';

(async () => {
expectType<RegExp>(emailRegex());
expectType<RegExp>(emailRegex({}));
expectType<RegExp>(emailRegex({ exact: true }));
})();
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
"node": ">=6"
},
"scripts": {
"test": "xo && ava"
"test": "xo && ava && tsd-check"
},
"files": [
"index.js"
"index.js",
"index.d.ts"
],
"keywords": [
"text",
Expand All @@ -34,6 +35,12 @@
],
"devDependencies": {
"ava": "*",
"tsd-check": "^0.3.0",
"xo": "*"
},
"xo": {
"ignores": [
"*.ts"
]
}
}

0 comments on commit 2ef1fc0

Please sign in to comment.