From 39921a065d61dd0e37490a46ce8df2a395895b4d Mon Sep 17 00:00:00 2001 From: Ivo Gabe de Wolff Date: Sat, 9 Aug 2014 12:03:14 +0200 Subject: [PATCH 1/2] RegExpExecArray should extends Array instead of copying all the methods of Array --- src/lib/core.d.ts | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/src/lib/core.d.ts b/src/lib/core.d.ts index c37efa0340a..eead3b8fe3d 100644 --- a/src/lib/core.d.ts +++ b/src/lib/core.d.ts @@ -775,36 +775,9 @@ declare var Date: { now(): number; } -interface RegExpExecArray { - [index: number]: string; - length: number; - +interface RegExpExecArray extends Array { index: number; input: string; - - toString(): string; - toLocaleString(): string; - concat(...items: string[][]): string[]; - join(separator?: string): string; - pop(): string; - push(...items: string[]): number; - reverse(): string[]; - shift(): string; - slice(start?: number, end?: number): string[]; - sort(compareFn?: (a: string, b: string) => number): string[]; - splice(start: number): string[]; - splice(start: number, deleteCount: number, ...items: string[]): string[]; - unshift(...items: string[]): number; - - indexOf(searchElement: string, fromIndex?: number): number; - lastIndexOf(searchElement: string, fromIndex?: number): number; - every(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean; - some(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): boolean; - forEach(callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any): void; - map(callbackfn: (value: string, index: number, array: string[]) => any, thisArg?: any): any[]; - filter(callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any): string[]; - reduce(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any; - reduceRight(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: string[]) => any, initialValue?: any): any; } From 8e8f5120533b9ccd8ae0c589a1cf13018bc0a452 Mon Sep 17 00:00:00 2001 From: Ivo Gabe de Wolff Date: Sat, 9 Aug 2014 12:06:52 +0200 Subject: [PATCH 2/2] Add optional index and output to String.match --- src/lib/core.d.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lib/core.d.ts b/src/lib/core.d.ts index eead3b8fe3d..607f6678c1a 100644 --- a/src/lib/core.d.ts +++ b/src/lib/core.d.ts @@ -302,13 +302,13 @@ interface String { * Matches a string with a regular expression, and returns an array containing the results of that search. * @param regexp A variable name or string literal containing the regular expression pattern and flags. */ - match(regexp: string): string[]; + match(regexp: string): RegExpMatchArray; /** * Matches a string with a regular expression, and returns an array containing the results of that search. * @param regexp A regular expression object that contains the regular expression pattern and applicable flags. */ - match(regexp: RegExp): string[]; + match(regexp: RegExp): RegExpMatchArray; /** * Replaces text in a string, using a regular expression or search string. @@ -775,12 +775,16 @@ declare var Date: { now(): number; } +interface RegExpMatchArray extends Array { + index?: number; + input?: string; +} + interface RegExpExecArray extends Array { index: number; input: string; } - interface RegExp { /** * Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search.