From 25d55b5101153ed14af334f72466f9ea2bf46107 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 19 Aug 2015 15:02:46 -0700 Subject: [PATCH] Added overload for 'String#replace' to take objects with '[Symbol.replace]' method. --- src/lib/es6.d.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/lib/es6.d.ts b/src/lib/es6.d.ts index f4c87636de..fddf9db79a 100644 --- a/src/lib/es6.d.ts +++ b/src/lib/es6.d.ts @@ -433,6 +433,20 @@ interface String { */ match(regexpLike: { [Symbol.match](string: string): RegExpMatchArray; }): RegExpMatchArray; + /** + * Replaces text in a string, using an object that supports replacement within a string. + * @param searchValue A object can search for and replace matches within a string. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. + */ + replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string; + + /** + * Replaces text in a string, using an object that supports replacement within a string. + * @param searchValue A object can search for and replace matches within a string. + * @param replacer A function that returns the replacement text. + */ + replace(searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string; + /** * Returns an HTML anchor element and sets the name attribute to the text value * @param name