Skip to content

Commit 851e335

Browse files
committed
Merge pull request #415 from ivogabe/regexp
RegExp function return types
2 parents c71e596 + 8e8f512 commit 851e335

File tree

1 file changed

+7
-30
lines changed

1 file changed

+7
-30
lines changed

src/lib/core.d.ts

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,13 @@ interface String {
302302
* Matches a string with a regular expression, and returns an array containing the results of that search.
303303
* @param regexp A variable name or string literal containing the regular expression pattern and flags.
304304
*/
305-
match(regexp: string): string[];
305+
match(regexp: string): RegExpMatchArray;
306306

307307
/**
308308
* Matches a string with a regular expression, and returns an array containing the results of that search.
309309
* @param regexp A regular expression object that contains the regular expression pattern and applicable flags.
310310
*/
311-
match(regexp: RegExp): string[];
311+
match(regexp: RegExp): RegExpMatchArray;
312312

313313
/**
314314
* Replaces text in a string, using a regular expression or search string.
@@ -775,39 +775,16 @@ declare var Date: {
775775
now(): number;
776776
}
777777

778-
interface RegExpExecArray {
779-
[index: number]: string;
780-
length: number;
778+
interface RegExpMatchArray extends Array<string> {
779+
index?: number;
780+
input?: string;
781+
}
781782

783+
interface RegExpExecArray extends Array<string> {
782784
index: number;
783785
input: string;
784-
785-
toString(): string;
786-
toLocaleString(): string;
787-
concat(...items: string[][]): string[];
788-
join(separator?: string): string;
789-
pop(): string;
790-
push(...items: string[]): number;
791-
reverse(): string[];
792-
shift(): string;
793-
slice(start?: number, end?: number): string[];
794-
sort(compareFn?: (a: string, b: string) => number): string[];
795-
splice(start: number): string[];
796-
splice(start: number, deleteCount: number, ...items: string[]): string[];
797-
unshift(...items: string[]): number;
798-
799-
indexOf(searchElement: string, fromIndex?: number): number;
800-
lastIndexOf(searchElement: string, fromIndex?: number): number;
801-
every(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean;
802-
some(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean;
803-
forEach(callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any): void;
804-
map(callbackfn: (value: string, index: number, array: string[]) => any, thisArg?: any): any[];
805-
filter(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): string[];
806-
reduce(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any;
807-
reduceRight(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any;
808786
}
809787

810-
811788
interface RegExp {
812789
/**
813790
* Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search.

0 commit comments

Comments
 (0)