Skip to content

Commit 25d55b5

Browse files
Added overload for 'String#replace' to take objects with '[Symbol.replace]' method.
1 parent 4dd701a commit 25d55b5

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/lib/es6.d.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,20 @@ interface String {
433433
*/
434434
match(regexpLike: { [Symbol.match](string: string): RegExpMatchArray; }): RegExpMatchArray;
435435

436+
/**
437+
* Replaces text in a string, using an object that supports replacement within a string.
438+
* @param searchValue A object can search for and replace matches within a string.
439+
* @param replaceValue A string containing the text to replace for every successful match of searchValue in this string.
440+
*/
441+
replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string;
442+
443+
/**
444+
* Replaces text in a string, using an object that supports replacement within a string.
445+
* @param searchValue A object can search for and replace matches within a string.
446+
* @param replacer A function that returns the replacement text.
447+
*/
448+
replace(searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string;
449+
436450
/**
437451
* Returns an <a> HTML anchor element and sets the name attribute to the text value
438452
* @param name

0 commit comments

Comments
 (0)