From 70c5fcaaa26043672ef0b3d6fe79d57405f92197 Mon Sep 17 00:00:00 2001 From: Pascal Sommer Date: Fri, 6 Feb 2026 23:51:37 +0100 Subject: [PATCH] Document indexOf return value when not found (#60569) Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com> --- src/lib/es2020.bigint.d.ts | 8 ++-- src/lib/es5.d.ts | 40 +++++++++---------- .../completionsStringMethods.baseline | 4 +- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/lib/es2020.bigint.d.ts b/src/lib/es2020.bigint.d.ts index f1f32823061..22b1b6c3e4b 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. @@ -514,7 +514,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. @@ -532,7 +532,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 c5e02c71c1c..43ff5837a95 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. */ @@ -1955,7 +1955,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. @@ -1970,7 +1970,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. @@ -2237,7 +2237,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. @@ -2252,7 +2252,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. @@ -2519,7 +2519,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. @@ -2534,7 +2534,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. @@ -2815,7 +2815,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. @@ -3082,7 +3082,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. @@ -3097,7 +3097,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. @@ -3363,7 +3363,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. @@ -3378,7 +3378,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. @@ -3644,7 +3644,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. @@ -3659,7 +3659,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. @@ -3926,7 +3926,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. @@ -3941,7 +3941,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. @@ -4208,7 +4208,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. @@ -4223,7 +4223,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. diff --git a/tests/baselines/reference/completionsStringMethods.baseline b/tests/baselines/reference/completionsStringMethods.baseline index 3935df481ea..e7e9cf31bfb 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" } ],