diff --git a/types/is-regex/index.d.ts b/types/is-regex/index.d.ts new file mode 100644 index 0000000000..96ec522bb1 --- /dev/null +++ b/types/is-regex/index.d.ts @@ -0,0 +1,11 @@ +// Type definitions for is-regex 1.0 +// Project: https://github.com/ljharb/is-regex +// Definitions by: Jordan Harband +// ExE Boss +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Returns whether the value is a valid `RegExp` object with the `[[RegExpMatcher]]` internal slot. + */ +declare function isRegex(value: any): value is RegExp; +export = isRegex; diff --git a/types/is-regex/is-regex-tests.ts b/types/is-regex/is-regex-tests.ts new file mode 100644 index 0000000000..72fbd6ddae --- /dev/null +++ b/types/is-regex/is-regex-tests.ts @@ -0,0 +1,7 @@ +import isRegExp = require('is-regex'); + +declare var any: unknown; + +if (isRegExp(any)) { + any; // $ExpectType RegExp +} diff --git a/types/is-regex/tsconfig.json b/types/is-regex/tsconfig.json new file mode 100644 index 0000000000..244c89726d --- /dev/null +++ b/types/is-regex/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["ES2015"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "is-regex-tests.ts", + "index.d.ts" + ] +} diff --git a/types/is-regex/tslint.json b/types/is-regex/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/is-regex/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }