mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Merge pull request #24640 from jewbre/feature/named-regexp-groups
Types for named regexp group
This commit is contained in:
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
// Type definitions for named-regexp-groups 1.0
|
||||
// Project: https://github.com/commenthol/named-regexp-groups/
|
||||
// Definitions by: Vilim Stubičan <https://github.com/jewbre>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
interface NamedRegExpExecArray extends RegExpExecArray {
|
||||
groups: { [propName: string]: string };
|
||||
}
|
||||
|
||||
declare class NamedRegExp {
|
||||
constructor(pattern?: string | RegExp, flags?: string);
|
||||
|
||||
/**
|
||||
* Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search.
|
||||
* @param string The String object or string literal on which to perform the search.
|
||||
*/
|
||||
exec(string: string): NamedRegExpExecArray | null;
|
||||
|
||||
/**
|
||||
* Returns a Boolean value that indicates whether or not a pattern exists in a searched string.
|
||||
* @param string String on which to perform the search.
|
||||
*/
|
||||
test(string: string): boolean;
|
||||
|
||||
// Non-standard extensions
|
||||
toString(): string;
|
||||
|
||||
[Symbol.replace](str: string, replacement: string | ((match: string, ...capturedGroups: string[]) => string)): string;
|
||||
|
||||
[Symbol.match](str: string): NamedRegExpExecArray;
|
||||
|
||||
[Symbol.split](str: string): string[];
|
||||
|
||||
[Symbol.search](str: string): number;
|
||||
}
|
||||
|
||||
export = NamedRegExp;
|
||||
@@ -0,0 +1,19 @@
|
||||
import NamedRegExp = require("named-regexp-groups");
|
||||
|
||||
// $ExpectType NamedRegExp
|
||||
new NamedRegExp('aaa', 'gi');
|
||||
|
||||
// $ExpectType NamedRegExp
|
||||
new NamedRegExp(/aaa/gi);
|
||||
|
||||
// $ExpectType NamedRegExp
|
||||
new NamedRegExp();
|
||||
|
||||
// $ExpectError
|
||||
new NamedRegExp(1);
|
||||
|
||||
// $ExpectError
|
||||
new NamedRegExp({});
|
||||
|
||||
// $ExpectError
|
||||
new NamedRegExp([]);
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"named-regexp-groups-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user