From 7901a397214e8c7b39de8954eecc707dce8cb099 Mon Sep 17 00:00:00 2001 From: BitFlippa27 <32537389+BitFlippa27@users.noreply.github.com> Date: Fri, 17 Jan 2025 00:58:51 +0100 Subject: [PATCH] Fix JSDoc for Array#sort, TypedArray#sort and Array#toSorted methods (#60983) --- src/lib/es2023.array.d.ts | 4 ++-- src/lib/es5.d.ts | 2 +- .../completionEntryForUnionMethod.baseline | 2 +- ...oToTypeDefinition_arrayType.baseline.jsonc | 4 ++-- tests/lib/lib.d.ts | 20 +++++++++---------- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/lib/es2023.array.d.ts b/src/lib/es2023.array.d.ts index 6615937424f..77f3766c5c7 100644 --- a/src/lib/es2023.array.d.ts +++ b/src/lib/es2023.array.d.ts @@ -31,7 +31,7 @@ interface Array { * Returns a copy of an array with its elements sorted. * @param compareFn Function used to determine the order of the elements. It is expected to return * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * value otherwise. If omitted, the elements are sorted in ascending, UTF-16 code unit order. * ```ts * [11, 2, 22, 1].toSorted((a, b) => a - b) // [1, 2, 11, 22] * ``` @@ -109,7 +109,7 @@ interface ReadonlyArray { * Copies and sorts the array. * @param compareFn Function used to determine the order of the elements. It is expected to return * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * value otherwise. If omitted, the elements are sorted in ascending, UTF-16 code unit order. * ```ts * [11, 2, 22, 1].toSorted((a, b) => a - b) // [1, 2, 11, 22] * ``` diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 2b0b01abe2c..ae5c1e2b60b 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1366,7 +1366,7 @@ interface Array { * This method mutates the array and returns a reference to the same array. * @param compareFn Function used to determine the order of the elements. It is expected to return * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive - * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * value otherwise. If omitted, the elements are sorted in ascending, UTF-16 code unit order. * ```ts * [11,2,22,1].sort((a, b) => a - b) * ``` diff --git a/tests/baselines/reference/completionEntryForUnionMethod.baseline b/tests/baselines/reference/completionEntryForUnionMethod.baseline index fac6df3daa6..4a503b4a10a 100644 --- a/tests/baselines/reference/completionEntryForUnionMethod.baseline +++ b/tests/baselines/reference/completionEntryForUnionMethod.baseline @@ -4190,7 +4190,7 @@ "kind": "space" }, { - "text": "Function used to determine the order of the elements. It is expected to return\na negative value if the first argument is less than the second argument, zero if they're equal, and a positive\nvalue otherwise. If omitted, the elements are sorted in ascending, ASCII character order.\n```ts\n[11,2,22,1].sort((a, b) => a - b)\n```", + "text": "Function used to determine the order of the elements. It is expected to return\na negative value if the first argument is less than the second argument, zero if they're equal, and a positive\nvalue otherwise. If omitted, the elements are sorted in ascending, UTF-16 code unit order.\n```ts\n[11,2,22,1].sort((a, b) => a - b)\n```", "kind": "text" } ] diff --git a/tests/baselines/reference/goToTypeDefinition_arrayType.baseline.jsonc b/tests/baselines/reference/goToTypeDefinition_arrayType.baseline.jsonc index 1dc5b63951e..5ae8068d951 100644 --- a/tests/baselines/reference/goToTypeDefinition_arrayType.baseline.jsonc +++ b/tests/baselines/reference/goToTypeDefinition_arrayType.baseline.jsonc @@ -78,7 +78,7 @@ // * This method mutates the array and returns a reference to the same array. // * @param compareFn Function used to determine the order of the elements. It is expected to return // * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive -// * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. +// * value otherwise. If omitted, the elements are sorted in ascending, UTF-16 code unit order. // * ```ts // * [11,2,22,1].sort((a, b) => a - b) // * ``` @@ -331,7 +331,7 @@ // * This method mutates the array and returns a reference to the same array. // * @param compareFn Function used to determine the order of the elements. It is expected to return // * a negative value if the first argument is less than the second argument, zero if they're equal, and a positive -// * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. +// * value otherwise. If omitted, the elements are sorted in ascending, UTF-16 code unit order. // * ```ts // * [11,2,22,1].sort((a, b) => a - b) // * ``` diff --git a/tests/lib/lib.d.ts b/tests/lib/lib.d.ts index 7266b020156..4bbda4f3b61 100644 --- a/tests/lib/lib.d.ts +++ b/tests/lib/lib.d.ts @@ -1068,7 +1068,7 @@ interface Array { /** * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. + * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, UTF-16 code unit order. */ sort(compareFn?: (a: T, b: T) => number): T[]; @@ -1612,7 +1612,7 @@ interface Int8Array { /** * Sorts an array. * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. + * omitted, the elements are sorted in ascending, numerical order. */ sort(compareFn?: (a: number, b: number) => number): Int8Array; @@ -1885,7 +1885,7 @@ interface Uint8Array { /** * Sorts an array. * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. + * omitted, the elements are sorted in ascending, numerical order. */ sort(compareFn?: (a: number, b: number) => number): Uint8Array; @@ -2159,7 +2159,7 @@ interface Uint8ClampedArray { /** * Sorts an array. * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. + * omitted, the elements are sorted in ascending, numerical order. */ sort(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; @@ -2432,7 +2432,7 @@ interface Int16Array { /** * Sorts an array. * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. + * omitted, the elements are sorted in ascending, numerical order. */ sort(compareFn?: (a: number, b: number) => number): Int16Array; @@ -2706,7 +2706,7 @@ interface Uint16Array { /** * Sorts an array. * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. + * omitted, the elements are sorted in ascending, numerical order. */ sort(compareFn?: (a: number, b: number) => number): Uint16Array; @@ -2979,7 +2979,7 @@ interface Int32Array { /** * Sorts an array. * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. + * omitted, the elements are sorted in ascending, numerical order. */ sort(compareFn?: (a: number, b: number) => number): Int32Array; @@ -3252,7 +3252,7 @@ interface Uint32Array { /** * Sorts an array. * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. + * omitted, the elements are sorted in ascending, numerical order. */ sort(compareFn?: (a: number, b: number) => number): Uint32Array; @@ -3525,7 +3525,7 @@ interface Float32Array { /** * Sorts an array. * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. + * omitted, the elements are sorted in ascending, numerical order. */ sort(compareFn?: (a: number, b: number) => number): Float32Array; @@ -3799,7 +3799,7 @@ interface Float64Array { /** * Sorts an array. * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. + * omitted, the elements are sorted in ascending, numerical order. */ sort(compareFn?: (a: number, b: number) => number): Float64Array;