From ed3d7f7d628eab70c49b8f639bf40d2349368645 Mon Sep 17 00:00:00 2001
From: Pascal Sommer
Date: Sat, 23 Nov 2024 14:44:33 +0100
Subject: [PATCH 1/2] Document indexOf return value when not found
---
src/lib/es2020.bigint.d.ts | 8 ++++----
src/lib/es5.d.ts | 40 +++++++++++++++++++-------------------
2 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/src/lib/es2020.bigint.d.ts b/src/lib/es2020.bigint.d.ts
index 05fbbf12ce146..6a126df856661 100644
--- a/src/lib/es2020.bigint.d.ts
+++ b/src/lib/es2020.bigint.d.ts
@@ -223,7 +223,7 @@ interface BigInt64Array
includes(searchElement: bigint, fromIndex?: number): boolean;
/**
- * Returns the index of the first occurrence of a value in an array.
+ * Returns the index of the first occurrence of a value in an array, or -1 if it is not present.
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
* search starts at index 0.
@@ -241,7 +241,7 @@ interface BigInt64Array
keys(): ArrayIterator;
/**
- * Returns the index of the last occurrence of a value in an array.
+ * Returns the index of the last occurrence of a value in an array, or -1 if it is not present.
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
* search starts at index 0.
@@ -500,7 +500,7 @@ interface BigUint64Array
includes(searchElement: bigint, fromIndex?: number): boolean;
/**
- * Returns the index of the first occurrence of a value in an array.
+ * Returns the index of the first occurrence of a value in an array, or -1 if it is not present.
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
* search starts at index 0.
@@ -518,7 +518,7 @@ interface BigUint64Array
keys(): ArrayIterator;
/**
- * Returns the index of the last occurrence of a value in an array.
+ * Returns the index of the last occurrence of a value in an array, or -1 if it is not present.
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
* search starts at index 0.
diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts
index ab484e1812e7b..f7581a1c78461 100644
--- a/src/lib/es5.d.ts
+++ b/src/lib/es5.d.ts
@@ -412,14 +412,14 @@ interface String {
concat(...strings: string[]): string;
/**
- * Returns the position of the first occurrence of a substring.
+ * Returns the position of the first occurrence of a substring, or -1 if it is not present.
* @param searchString The substring to search for in the string
* @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string.
*/
indexOf(searchString: string, position?: number): number;
/**
- * Returns the last occurrence of a substring in the string.
+ * Returns the last occurrence of a substring in the string, or -1 if it is not present.
* @param searchString The substring to search for.
* @param position The index at which to begin searching. If omitted, the search begins at the end of the string.
*/
@@ -1948,7 +1948,7 @@ interface Int8Array {
forEach(callbackfn: (value: number, index: number, array: this) => void, thisArg?: any): void;
/**
- * Returns the index of the first occurrence of a value in an array.
+ * Returns the index of the first occurrence of a value in an array, or -1 if it is not present.
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
* search starts at index 0.
@@ -1963,7 +1963,7 @@ interface Int8Array {
join(separator?: string): string;
/**
- * Returns the index of the last occurrence of a value in an array.
+ * Returns the index of the last occurrence of a value in an array, or -1 if it is not present.
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
* search starts at index 0.
@@ -2229,7 +2229,7 @@ interface Uint8Array {
forEach(callbackfn: (value: number, index: number, array: this) => void, thisArg?: any): void;
/**
- * Returns the index of the first occurrence of a value in an array.
+ * Returns the index of the first occurrence of a value in an array, or -1 if it is not present.
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
* search starts at index 0.
@@ -2244,7 +2244,7 @@ interface Uint8Array {
join(separator?: string): string;
/**
- * Returns the index of the last occurrence of a value in an array.
+ * Returns the index of the last occurrence of a value in an array, or -1 if it is not present.
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
* search starts at index 0.
@@ -2510,7 +2510,7 @@ interface Uint8ClampedArray void, thisArg?: any): void;
/**
- * Returns the index of the first occurrence of a value in an array.
+ * Returns the index of the first occurrence of a value in an array, or -1 if it is not present.
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
* search starts at index 0.
@@ -2525,7 +2525,7 @@ interface Uint8ClampedArray {
*/
forEach(callbackfn: (value: number, index: number, array: this) => void, thisArg?: any): void;
/**
- * Returns the index of the first occurrence of a value in an array.
+ * Returns the index of the first occurrence of a value in an array, or -1 if it is not present.
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
* search starts at index 0.
@@ -2805,7 +2805,7 @@ interface Int16Array {
join(separator?: string): string;
/**
- * Returns the index of the last occurrence of a value in an array.
+ * Returns the index of the last occurrence of a value in an array, or -1 if it is not present.
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
* search starts at index 0.
@@ -3071,7 +3071,7 @@ interface Uint16Array {
forEach(callbackfn: (value: number, index: number, array: this) => void, thisArg?: any): void;
/**
- * Returns the index of the first occurrence of a value in an array.
+ * Returns the index of the first occurrence of a value in an array, or -1 if it is not present.
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
* search starts at index 0.
@@ -3086,7 +3086,7 @@ interface Uint16Array {
join(separator?: string): string;
/**
- * Returns the index of the last occurrence of a value in an array.
+ * Returns the index of the last occurrence of a value in an array, or -1 if it is not present.
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
* search starts at index 0.
@@ -3351,7 +3351,7 @@ interface Int32Array {
forEach(callbackfn: (value: number, index: number, array: this) => void, thisArg?: any): void;
/**
- * Returns the index of the first occurrence of a value in an array.
+ * Returns the index of the first occurrence of a value in an array, or -1 if it is not present.
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
* search starts at index 0.
@@ -3366,7 +3366,7 @@ interface Int32Array {
join(separator?: string): string;
/**
- * Returns the index of the last occurrence of a value in an array.
+ * Returns the index of the last occurrence of a value in an array, or -1 if it is not present.
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
* search starts at index 0.
@@ -3631,7 +3631,7 @@ interface Uint32Array {
*/
forEach(callbackfn: (value: number, index: number, array: this) => void, thisArg?: any): void;
/**
- * Returns the index of the first occurrence of a value in an array.
+ * Returns the index of the first occurrence of a value in an array, or -1 if it is not present.
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
* search starts at index 0.
@@ -3646,7 +3646,7 @@ interface Uint32Array {
join(separator?: string): string;
/**
- * Returns the index of the last occurrence of a value in an array.
+ * Returns the index of the last occurrence of a value in an array, or -1 if it is not present.
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
* search starts at index 0.
@@ -3912,7 +3912,7 @@ interface Float32Array {
forEach(callbackfn: (value: number, index: number, array: this) => void, thisArg?: any): void;
/**
- * Returns the index of the first occurrence of a value in an array.
+ * Returns the index of the first occurrence of a value in an array, or -1 if it is not present.
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
* search starts at index 0.
@@ -3927,7 +3927,7 @@ interface Float32Array {
join(separator?: string): string;
/**
- * Returns the index of the last occurrence of a value in an array.
+ * Returns the index of the last occurrence of a value in an array, or -1 if it is not present.
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
* search starts at index 0.
@@ -4193,7 +4193,7 @@ interface Float64Array {
forEach(callbackfn: (value: number, index: number, array: this) => void, thisArg?: any): void;
/**
- * Returns the index of the first occurrence of a value in an array.
+ * Returns the index of the first occurrence of a value in an array, or -1 if it is not present.
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
* search starts at index 0.
@@ -4208,7 +4208,7 @@ interface Float64Array {
join(separator?: string): string;
/**
- * Returns the index of the last occurrence of a value in an array.
+ * Returns the index of the last occurrence of a value in an array, or -1 if it is not present.
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the
* search starts at index 0.
From 628a520bc033b780d1d48986593805005593f547 Mon Sep 17 00:00:00 2001
From: Pascal Sommer
Date: Thu, 28 Nov 2024 23:39:11 +0100
Subject: [PATCH 2/2] Update tests with changed docstrings
---
tests/baselines/reference/1.0lib-noErrors.js | 7 ++++---
tests/baselines/reference/1.0lib-noErrors.symbols | 4 ++--
tests/baselines/reference/1.0lib-noErrors.types | 4 ++--
.../baselines/reference/completionsStringMethods.baseline | 4 ++--
tests/cases/conformance/decorators/1.0lib-noErrors.ts | 6 +++---
5 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/tests/baselines/reference/1.0lib-noErrors.js b/tests/baselines/reference/1.0lib-noErrors.js
index b190ac91b1594..fc49f788730ec 100644
--- a/tests/baselines/reference/1.0lib-noErrors.js
+++ b/tests/baselines/reference/1.0lib-noErrors.js
@@ -297,14 +297,14 @@ interface String {
concat(...strings: string[]): string;
/**
- * Returns the position of the first occurrence of a substring.
+ * Returns the position of the first occurrence of a substring, or -1 if it is not present.
* @param searchString The substring to search for in the string
* @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string.
*/
indexOf(searchString: string, position?: number): number;
/**
- * Returns the last occurrence of a substring in the string.
+ * Returns the last occurrence of a substring in the string, or -1 if it is not present.
* @param searchString The substring to search for.
* @param position The index at which to begin searching. If omitted, the search begins at the end of the string.
*/
@@ -1143,7 +1143,8 @@ declare var Array: {
(...items: T[]): T[];
isArray(arg: any): boolean;
prototype: Array;
-}
+}
+
//// [1.0lib-noErrors.js]
/* *****************************************************************************
diff --git a/tests/baselines/reference/1.0lib-noErrors.symbols b/tests/baselines/reference/1.0lib-noErrors.symbols
index 5ac0014e33ed1..2b0cef1ee8f89 100644
--- a/tests/baselines/reference/1.0lib-noErrors.symbols
+++ b/tests/baselines/reference/1.0lib-noErrors.symbols
@@ -440,7 +440,7 @@ interface String {
>strings : Symbol(strings, Decl(1.0lib-noErrors.ts, 293, 11))
/**
- * Returns the position of the first occurrence of a substring.
+ * Returns the position of the first occurrence of a substring, or -1 if it is not present.
* @param searchString The substring to search for in the string
* @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string.
*/
@@ -450,7 +450,7 @@ interface String {
>position : Symbol(position, Decl(1.0lib-noErrors.ts, 300, 33))
/**
- * Returns the last occurrence of a substring in the string.
+ * Returns the last occurrence of a substring in the string, or -1 if it is not present.
* @param searchString The substring to search for.
* @param position The index at which to begin searching. If omitted, the search begins at the end of the string.
*/
diff --git a/tests/baselines/reference/1.0lib-noErrors.types b/tests/baselines/reference/1.0lib-noErrors.types
index f7d94356d476b..d36516c82e1ab 100644
--- a/tests/baselines/reference/1.0lib-noErrors.types
+++ b/tests/baselines/reference/1.0lib-noErrors.types
@@ -491,7 +491,7 @@ interface String {
> : ^^^^^^^^
/**
- * Returns the position of the first occurrence of a substring.
+ * Returns the position of the first occurrence of a substring, or -1 if it is not present.
* @param searchString The substring to search for in the string
* @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string.
*/
@@ -504,7 +504,7 @@ interface String {
> : ^^^^^^
/**
- * Returns the last occurrence of a substring in the string.
+ * Returns the last occurrence of a substring in the string, or -1 if it is not present.
* @param searchString The substring to search for.
* @param position The index at which to begin searching. If omitted, the search begins at the end of the string.
*/
diff --git a/tests/baselines/reference/completionsStringMethods.baseline b/tests/baselines/reference/completionsStringMethods.baseline
index bf00835b43760..c1b618086f6f1 100644
--- a/tests/baselines/reference/completionsStringMethods.baseline
+++ b/tests/baselines/reference/completionsStringMethods.baseline
@@ -443,7 +443,7 @@
],
"documentation": [
{
- "text": "Returns the position of the first occurrence of a substring.",
+ "text": "Returns the position of the first occurrence of a substring, or -1 if it is not present.",
"kind": "text"
}
],
@@ -585,7 +585,7 @@
],
"documentation": [
{
- "text": "Returns the last occurrence of a substring in the string.",
+ "text": "Returns the last occurrence of a substring in the string, or -1 if it is not present.",
"kind": "text"
}
],
diff --git a/tests/cases/conformance/decorators/1.0lib-noErrors.ts b/tests/cases/conformance/decorators/1.0lib-noErrors.ts
index e170df0c9bf6a..02de2d9aa0d16 100644
--- a/tests/cases/conformance/decorators/1.0lib-noErrors.ts
+++ b/tests/cases/conformance/decorators/1.0lib-noErrors.ts
@@ -295,14 +295,14 @@ interface String {
concat(...strings: string[]): string;
/**
- * Returns the position of the first occurrence of a substring.
+ * Returns the position of the first occurrence of a substring, or -1 if it is not present.
* @param searchString The substring to search for in the string
* @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string.
*/
indexOf(searchString: string, position?: number): number;
/**
- * Returns the last occurrence of a substring in the string.
+ * Returns the last occurrence of a substring in the string, or -1 if it is not present.
* @param searchString The substring to search for.
* @param position The index at which to begin searching. If omitted, the search begins at the end of the string.
*/
@@ -1141,4 +1141,4 @@ declare var Array: {
(...items: T[]): T[];
isArray(arg: any): boolean;
prototype: Array;
-}
\ No newline at end of file
+}