From 3cade4ca240b6abb33706c2df87553abd6d32088 Mon Sep 17 00:00:00 2001 From: navya9singh Date: Mon, 25 Jul 2022 11:53:20 -0700 Subject: [PATCH 1/9] String.prototype.replace docs fix. Co-authored-by: graphemecluster --- src/lib/es2015.symbol.wellknown.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/es2015.symbol.wellknown.d.ts b/src/lib/es2015.symbol.wellknown.d.ts index 8911baa9bb9cf..69914a9d5576c 100644 --- a/src/lib/es2015.symbol.wellknown.d.ts +++ b/src/lib/es2015.symbol.wellknown.d.ts @@ -219,9 +219,9 @@ interface String { match(matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null; /** - * Replaces first match with string or all matches with RegExp. - * @param searchValue A string or RegExp search value. - * @param replaceValue A string containing the text to replace for match. + * Replaces one or more occurrences of substrings that match the method provided by `searchValue`. + * @param searchValue An object that supports searching for and replacing matches within a string. + * @param replacer A function that returns the replacement text. */ replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string; From 04df1e18d9161035a18e0ea44eec8d1ce7d4f39d Mon Sep 17 00:00:00 2001 From: navya9singh Date: Mon, 25 Jul 2022 12:25:45 -0700 Subject: [PATCH 2/9] Follow up changes to es5.d.ts --- src/lib/es5.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index b062a920c37c3..a743cb0a073fb 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -430,7 +430,7 @@ interface String { /** * Replaces text in a string, using a regular expression or search string. * @param searchValue A string to search for. - * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. + * @param replaceValue A string containing the text to replace. When the searchvalue is a string, only the first match is replaced. If the searchValue is a Regexp, all matches are replaced if the g flag is set. Otherwise only the first one is. */ replace(searchValue: string | RegExp, replaceValue: string): string; From 34c3b9cf49841391384f397ad3c49cfed9438b2b Mon Sep 17 00:00:00 2001 From: navya9singh Date: Mon, 25 Jul 2022 14:26:09 -0700 Subject: [PATCH 3/9] Fixed changes to previous commit: Co-authored-by: graphemecluster --- src/lib/es2015.symbol.wellknown.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/es2015.symbol.wellknown.d.ts b/src/lib/es2015.symbol.wellknown.d.ts index 69914a9d5576c..c8250c10a20cb 100644 --- a/src/lib/es2015.symbol.wellknown.d.ts +++ b/src/lib/es2015.symbol.wellknown.d.ts @@ -221,7 +221,7 @@ interface String { /** * Replaces one or more occurrences of substrings that match the method provided by `searchValue`. * @param searchValue An object that supports searching for and replacing matches within a string. - * @param replacer A function that returns the replacement text. + * @param replacer The replacement text. */ replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string; From 472584f9cdad7f1ac6c19c0313c59637c71b94b3 Mon Sep 17 00:00:00 2001 From: navya9singh Date: Wed, 27 Jul 2022 13:18:35 -0700 Subject: [PATCH 4/9] Changes to resolve pr comments --- src/lib/es2015.symbol.wellknown.d.ts | 4 +- src/lib/es5.d.ts | 4 +- .../completionsStringMethods.baseline | 50 ++++++++++++++++++- 3 files changed, 52 insertions(+), 6 deletions(-) diff --git a/src/lib/es2015.symbol.wellknown.d.ts b/src/lib/es2015.symbol.wellknown.d.ts index c8250c10a20cb..cbac3ba5682b8 100644 --- a/src/lib/es2015.symbol.wellknown.d.ts +++ b/src/lib/es2015.symbol.wellknown.d.ts @@ -219,9 +219,9 @@ interface String { match(matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null; /** - * Replaces one or more occurrences of substrings that match the method provided by `searchValue`. + * Passes a string and {@linkcode replaceValue} to the [Symbol.replace] method on {@linkcode searchValue}. This method is expected to implement its own replacement algorithm. * @param searchValue An object that supports searching for and replacing matches within a string. - * @param replacer The replacement text. + * @param replaceValue The replacement text. */ replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string; diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index a743cb0a073fb..43f30e668d99a 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -429,8 +429,8 @@ interface String { /** * Replaces text in a string, using a regular expression or search string. - * @param searchValue A string to search for. - * @param replaceValue A string containing the text to replace. When the searchvalue is a string, only the first match is replaced. If the searchValue is a Regexp, all matches are replaced if the g flag is set. Otherwise only the first one is. + * @param searchValue A string or regular expression to search for. + * @param replaceValue A string containing the text to replace. When the {@linkcode searchValue} is a string, only the first match is replaced. If the {@linkcode searchValue} is a RegExp, all matches are replaced if the g flag is set. Otherwise only the first one is. */ replace(searchValue: string | RegExp, replaceValue: string): string; diff --git a/tests/baselines/reference/completionsStringMethods.baseline b/tests/baselines/reference/completionsStringMethods.baseline index 0d3fe39d755c9..00fde327a214c 100644 --- a/tests/baselines/reference/completionsStringMethods.baseline +++ b/tests/baselines/reference/completionsStringMethods.baseline @@ -1048,7 +1048,7 @@ "kind": "space" }, { - "text": "A string to search for.", + "text": "A string or regular expression to search for.", "kind": "text" } ] @@ -1065,7 +1065,53 @@ "kind": "space" }, { - "text": "A string containing the text to replace for every successful match of searchValue in this string.", + "text": "A string containing the text to replace. When the ", + "kind": "text" + }, + { + "text": "{@linkcode ", + "kind": "link" + }, + { + "text": "searchValue", + "kind": "linkName", + "target": { + "fileName": "lib.d.ts", + "textSpan": { + "start": 19079, + "length": 28 + } + } + }, + { + "text": "}", + "kind": "link" + }, + { + "text": " is a string, only the first match is replaced. If the ", + "kind": "text" + }, + { + "text": "{@linkcode ", + "kind": "link" + }, + { + "text": "searchValue", + "kind": "linkName", + "target": { + "fileName": "lib.d.ts", + "textSpan": { + "start": 19079, + "length": 28 + } + } + }, + { + "text": "}", + "kind": "link" + }, + { + "text": " is a RegExp, all matches are replaced if the g flag is set. Otherwise only the first one is.", "kind": "text" } ] From 29e50b314900d22b08f6472918f59ae2b40aba08 Mon Sep 17 00:00:00 2001 From: navya9singh Date: Fri, 16 Sep 2022 11:07:15 -0700 Subject: [PATCH 5/9] Rewording documentation --- src/lib/es2015.symbol.wellknown.d.ts | 2 +- src/lib/es5.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/es2015.symbol.wellknown.d.ts b/src/lib/es2015.symbol.wellknown.d.ts index cbac3ba5682b8..f27dc68850016 100644 --- a/src/lib/es2015.symbol.wellknown.d.ts +++ b/src/lib/es2015.symbol.wellknown.d.ts @@ -219,7 +219,7 @@ interface String { match(matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null; /** - * Passes a string and {@linkcode replaceValue} to the [Symbol.replace] method on {@linkcode searchValue}. This method is expected to implement its own replacement algorithm. + * Passes a string and {@linkcode replaceValue} to the `[Symbol.replace]` method on {@linkcode searchValue}. This method is expected to implement its own replacement algorithm. * @param searchValue An object that supports searching for and replacing matches within a string. * @param replaceValue The replacement text. */ diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 43f30e668d99a..8fcc47e708b50 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -430,7 +430,7 @@ interface String { /** * Replaces text in a string, using a regular expression or search string. * @param searchValue A string or regular expression to search for. - * @param replaceValue A string containing the text to replace. When the {@linkcode searchValue} is a string, only the first match is replaced. If the {@linkcode searchValue} is a RegExp, all matches are replaced if the g flag is set. Otherwise only the first one is. + * @param replaceValue A string containing the text to replace. When the {@linkcode searchValue} is a RegExp, all matches are replaced if the g flag is set (taking into account the y flag if present). Otherwise {@linkcode searchValue} only the first match is replaced. */ replace(searchValue: string | RegExp, replaceValue: string): string; From 05071920a03f8ea530fe01f79f2537c999ec8b02 Mon Sep 17 00:00:00 2001 From: navya9singh Date: Fri, 16 Sep 2022 11:54:52 -0700 Subject: [PATCH 6/9] Accepting baselines --- .../baselines/reference/completionsStringMethods.baseline | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/baselines/reference/completionsStringMethods.baseline b/tests/baselines/reference/completionsStringMethods.baseline index 00fde327a214c..7e356829dd331 100644 --- a/tests/baselines/reference/completionsStringMethods.baseline +++ b/tests/baselines/reference/completionsStringMethods.baseline @@ -1078,7 +1078,7 @@ "target": { "fileName": "lib.d.ts", "textSpan": { - "start": 19079, + "start": 19080, "length": 28 } } @@ -1088,7 +1088,7 @@ "kind": "link" }, { - "text": " is a string, only the first match is replaced. If the ", + "text": " is a RegExp, all matches are replaced if the g flag is set (taking into account the y flag if present). Otherwise ", "kind": "text" }, { @@ -1101,7 +1101,7 @@ "target": { "fileName": "lib.d.ts", "textSpan": { - "start": 19079, + "start": 19080, "length": 28 } } @@ -1111,7 +1111,7 @@ "kind": "link" }, { - "text": " is a RegExp, all matches are replaced if the g flag is set. Otherwise only the first one is.", + "text": " only the first match is replaced.", "kind": "text" } ] From 906510e0f30590a4c8fdc892905ccb8dbe512e3d Mon Sep 17 00:00:00 2001 From: navya9singh Date: Fri, 16 Sep 2022 15:36:21 -0700 Subject: [PATCH 7/9] Fixes for pr --- src/lib/es5.d.ts | 2 +- .../baselines/reference/completionsStringMethods.baseline | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 8fcc47e708b50..1d36ad18047a4 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -430,7 +430,7 @@ interface String { /** * Replaces text in a string, using a regular expression or search string. * @param searchValue A string or regular expression to search for. - * @param replaceValue A string containing the text to replace. When the {@linkcode searchValue} is a RegExp, all matches are replaced if the g flag is set (taking into account the y flag if present). Otherwise {@linkcode searchValue} only the first match is replaced. + * @param replaceValue A string containing the text to replace. When the {@linkcode searchValue} is a `RegExp`, all matches are replaced if the `g` flag is set (or only those matches at the beginning, if the `y` flag if present). Otherwise, only the first match of {@linkcode searchValue} is replaced. */ replace(searchValue: string | RegExp, replaceValue: string): string; diff --git a/tests/baselines/reference/completionsStringMethods.baseline b/tests/baselines/reference/completionsStringMethods.baseline index 7e356829dd331..2d53d3ffbeda8 100644 --- a/tests/baselines/reference/completionsStringMethods.baseline +++ b/tests/baselines/reference/completionsStringMethods.baseline @@ -1078,7 +1078,7 @@ "target": { "fileName": "lib.d.ts", "textSpan": { - "start": 19080, + "start": 19113, "length": 28 } } @@ -1088,7 +1088,7 @@ "kind": "link" }, { - "text": " is a RegExp, all matches are replaced if the g flag is set (taking into account the y flag if present). Otherwise ", + "text": " is a `RegExp`, all matches are replaced if the `g` flag is set (or only those matches at the beginning, if the `y` flag if present). Otherwise, only the first match of ", "kind": "text" }, { @@ -1101,7 +1101,7 @@ "target": { "fileName": "lib.d.ts", "textSpan": { - "start": 19080, + "start": 19113, "length": 28 } } @@ -1111,7 +1111,7 @@ "kind": "link" }, { - "text": " only the first match is replaced.", + "text": " is replaced.", "kind": "text" } ] From abc58bdabcf536bd5204fbc84fb7f45d75f1a9ad Mon Sep 17 00:00:00 2001 From: navya9singh Date: Tue, 20 Sep 2022 12:09:04 -0700 Subject: [PATCH 8/9] Fixing baseline errors --- tests/baselines/reference/completionsStringMethods.baseline | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/baselines/reference/completionsStringMethods.baseline b/tests/baselines/reference/completionsStringMethods.baseline index 2d53d3ffbeda8..78080c9897091 100644 --- a/tests/baselines/reference/completionsStringMethods.baseline +++ b/tests/baselines/reference/completionsStringMethods.baseline @@ -1078,7 +1078,7 @@ "target": { "fileName": "lib.d.ts", "textSpan": { - "start": 19113, + "start": 18875, "length": 28 } } @@ -1101,7 +1101,7 @@ "target": { "fileName": "lib.d.ts", "textSpan": { - "start": 19113, + "start": 18875, "length": 28 } } From 8e71f429c811ac7811533d7b0e02c32bad5a1b47 Mon Sep 17 00:00:00 2001 From: navya9singh Date: Sun, 25 Sep 2022 23:12:07 -0700 Subject: [PATCH 9/9] Fixing pr comments --- src/lib/es5.d.ts | 2 +- tests/baselines/reference/completionsStringMethods.baseline | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 154351ba26c27..99ae47ce9c4f9 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -424,7 +424,7 @@ interface String { /** * Replaces text in a string, using a regular expression or search string. * @param searchValue A string or regular expression to search for. - * @param replaceValue A string containing the text to replace. When the {@linkcode searchValue} is a `RegExp`, all matches are replaced if the `g` flag is set (or only those matches at the beginning, if the `y` flag if present). Otherwise, only the first match of {@linkcode searchValue} is replaced. + * @param replaceValue A string containing the text to replace. When the {@linkcode searchValue} is a `RegExp`, all matches are replaced if the `g` flag is set (or only those matches at the beginning, if the `y` flag is also present). Otherwise, only the first match of {@linkcode searchValue} is replaced. */ replace(searchValue: string | RegExp, replaceValue: string): string; diff --git a/tests/baselines/reference/completionsStringMethods.baseline b/tests/baselines/reference/completionsStringMethods.baseline index 78080c9897091..7f560b27e947e 100644 --- a/tests/baselines/reference/completionsStringMethods.baseline +++ b/tests/baselines/reference/completionsStringMethods.baseline @@ -1078,7 +1078,7 @@ "target": { "fileName": "lib.d.ts", "textSpan": { - "start": 18875, + "start": 18880, "length": 28 } } @@ -1088,7 +1088,7 @@ "kind": "link" }, { - "text": " is a `RegExp`, all matches are replaced if the `g` flag is set (or only those matches at the beginning, if the `y` flag if present). Otherwise, only the first match of ", + "text": " is a `RegExp`, all matches are replaced if the `g` flag is set (or only those matches at the beginning, if the `y` flag is also present). Otherwise, only the first match of ", "kind": "text" }, { @@ -1101,7 +1101,7 @@ "target": { "fileName": "lib.d.ts", "textSpan": { - "start": 18875, + "start": 18880, "length": 28 } }