From d1ee4a67d6f2b2520dd525c749bc3340b7274641 Mon Sep 17 00:00:00 2001 From: JulianTaub Date: Thu, 6 Feb 2025 13:12:11 -0500 Subject: [PATCH 1/5] Adds proper description of 'deleteCount' argument for the 'splice' function --- src/lib/es5.d.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 786c953b42c74..d499e3a684154 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1375,14 +1375,20 @@ interface Array { /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. - * @param deleteCount The number of elements to remove. + * @param deleteCount The number of elements to remove. Omitting this argument will remove all elements from the start + * paramater location to end of the array. If value of this argument is either a negative number, zero, undefined, or a type + * that cannot be coverted to an integer, the function will evaluate the argument as zero and not remove any elements. * @returns An array containing the elements that were deleted. */ splice(start: number, deleteCount?: number): T[]; /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. - * @param deleteCount The number of elements to remove. + * @param deleteCount The number of elements to remove. If value of this argument is either a negative number, zero, + * undefined, or a type that cannot be coverted to an integer, the function will evaluate the argument as zero and + * not remove any elements. + * Note: If the deleteCount argument is left empty between the start and items arguments, it will not be evaluated as + * an omission. Instead, it will be evaluated as undefined, which will be evaluated as zero. * @param items Elements to insert into the array in place of the deleted elements. * @returns An array containing the elements that were deleted. */ From f5ba5a9ac03eae54941145e1b214f582370598c9 Mon Sep 17 00:00:00 2001 From: JulianTaub Date: Thu, 6 Feb 2025 13:22:07 -0500 Subject: [PATCH 2/5] Adds proper description of 'deleteCount' argument for the 'splice' function in tests/lib --- tests/lib/lib.d.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/lib/lib.d.ts b/tests/lib/lib.d.ts index 4bbda4f3b6130..b7cdb25b69999 100644 --- a/tests/lib/lib.d.ts +++ b/tests/lib/lib.d.ts @@ -1078,10 +1078,23 @@ interface Array { */ splice(start: number): T[]; + /** + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. Omitting this argument will remove all elements from the start + * paramater location to end of the array. If value of this argument is either a negative number, zero, undefined, or a type + * that cannot be coverted to an integer, the function will evaluate the argument as zero and not remove any elements. + */ + splice(start: number, deleteCount?: number): T[]; + /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. - * @param deleteCount The number of elements to remove. + * @param deleteCount The number of elements to remove. If value of this argument is either a negative number, zero, + * undefined, or a type that cannot be coverted to an integer, the function will evaluate the argument as zero and + * not remove any elements. + * Note: If the deleteCount argument is left empty between the start and items arguments, it will not be evaluated as + * an omission. Instead, it will be evaluated as undefined, which will be evaluated as zero. * @param items Elements to insert into the array in place of the deleted elements. */ splice(start: number, deleteCount: number, ...items: T[]): T[]; From b80dfc458e57395314350f2e9027fa7326d8a7c3 Mon Sep 17 00:00:00 2001 From: JulianTaub Date: Fri, 14 Feb 2025 16:58:28 -0500 Subject: [PATCH 3/5] Adds deleteCount compiler and fourslash tests. Adds baseline refrence files --- .../arraySpliceParamDescription.errors.txt | 66 ++ .../reference/arraySpliceParamDescription.js | 86 ++ .../arraySpliceParamDescription.symbols | 155 ++++ .../arraySpliceParamDescription.types | 393 +++++++++ .../arraySpliceSignatureHelp.baseline | 830 ++++++++++++++++++ .../completionEntryForUnionMethod.baseline | 2 +- ...oToTypeDefinition_arrayType.baseline.jsonc | 20 +- .../compiler/arraySpliceParamDescription.ts | 43 + .../fourslash/arraySpliceSignatureHelp.ts | 10 + 9 files changed, 1600 insertions(+), 5 deletions(-) create mode 100644 tests/baselines/reference/arraySpliceParamDescription.errors.txt create mode 100644 tests/baselines/reference/arraySpliceParamDescription.js create mode 100644 tests/baselines/reference/arraySpliceParamDescription.symbols create mode 100644 tests/baselines/reference/arraySpliceParamDescription.types create mode 100644 tests/baselines/reference/arraySpliceSignatureHelp.baseline create mode 100644 tests/cases/compiler/arraySpliceParamDescription.ts create mode 100644 tests/cases/fourslash/arraySpliceSignatureHelp.ts diff --git a/tests/baselines/reference/arraySpliceParamDescription.errors.txt b/tests/baselines/reference/arraySpliceParamDescription.errors.txt new file mode 100644 index 0000000000000..f7af5c66d20ce --- /dev/null +++ b/tests/baselines/reference/arraySpliceParamDescription.errors.txt @@ -0,0 +1,66 @@ +arraySpliceParamDescription.ts(12,34): error TS2769: No overload matches this call. + Overload 1 of 2, '(start: number, deleteCount?: number): string[]', gave the following error. + Argument of type 'string' is not assignable to parameter of type 'number'. + Overload 2 of 2, '(start: number, deleteCount: number, ...items: string[]): string[]', gave the following error. + Argument of type 'string' is not assignable to parameter of type 'number'. +arraySpliceParamDescription.ts(32,34): error TS1135: Argument expression expected. +arraySpliceParamDescription.ts(32,36): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +arraySpliceParamDescription.ts(34,34): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. + + +==== arraySpliceParamDescription.ts (4 errors) ==== + // @target es5 + + export function isEmptyArr(l: { length: number }) { + return l.length === 0 + } + + var arrA : string[] + arrA = ["a", "b", "c", "d", "e", "f", "g"] + + // deleteCount param: undefined | NaN | 0 | -int; no elements removed + var undefSplice1 = arrA.splice(2, undefined) // OK + var charSplice1 = arrA.splice(2, "a") // expect error + ~~~ +!!! error TS2769: No overload matches this call. +!!! error TS2769: Overload 1 of 2, '(start: number, deleteCount?: number): string[]', gave the following error. +!!! error TS2769: Argument of type 'string' is not assignable to parameter of type 'number'. +!!! error TS2769: Overload 2 of 2, '(start: number, deleteCount: number, ...items: string[]): string[]', gave the following error. +!!! error TS2769: Argument of type 'string' is not assignable to parameter of type 'number'. + var naNSplice1 = arrA.splice(2, NaN) // OK + var zeroSplice1 = arrA.splice(2, 0) // OK + var negSplice1 = arrA.splice(2, -2) // OK and expect arrA = ["a", "b", "c", "d", "e", "f", "g"] + + // deleteCount param omitted; All elements after start param are removed + var omitSplice1 = arrA.splice(2,) // OK expect arrA = ["a", "b"] + + // testing the splice arrays are empty + isEmptyArr(undefSplice1) // OK and true + isEmptyArr(charSplice1) // OK and true + isEmptyArr(naNSplice1) // OK and true + isEmptyArr(zeroSplice1) // OK and true + isEmptyArr(negSplice1) // OK and true + isEmptyArr(omitSplice1) // OK and false. length of removed elements is 5 + + var arrB : string[] + arrB = ["a", "b", "c", "d", "e", "f", "g"] + + var undefSplice2 = arrB.splice(2, undefined, "h", "i") // expect error and arrB = ["a", "b", "h", "i", "e", "f", "g"] + var omitSplice2 = arrB.splice(2, , "j", "k") // expect error and arrB = ["a", "b", "j", "k", "e", "f", "g"] + ~ +!!! error TS1135: Argument expression expected. + ~~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. + var naNSplice2 = arrB.splice(2, NaN, "l", "m") // OK and arrB = ["a", "b", "l", "m", "e", "f", "g"] + var charSplice2 = arrB.splice(2, "a", "n", "o") // expect error and arrB = ["a", "b", "n", "o", "e", "f", "g"] + ~~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. + var zeroSplice2 = arrB.splice(2, 0, "p", "q") // OK and arrB = ["a", "b", "p", "q", "e", "f", "g"] + var negSplice2 = arrB.splice(2, -2, "r", "s") // OK and arrB = ["a", "b", "r", "s", "e", "f", "g"] + + isEmptyArr(undefSplice2) // OK and true + isEmptyArr(omitSplice2) // OK and true + isEmptyArr(naNSplice2) // OK and true + isEmptyArr(charSplice2) // OK and true + isEmptyArr(zeroSplice2) // OK and true + isEmptyArr(negSplice2) // OK and true \ No newline at end of file diff --git a/tests/baselines/reference/arraySpliceParamDescription.js b/tests/baselines/reference/arraySpliceParamDescription.js new file mode 100644 index 0000000000000..2723bd496c37c --- /dev/null +++ b/tests/baselines/reference/arraySpliceParamDescription.js @@ -0,0 +1,86 @@ +//// [tests/cases/compiler/arraySpliceParamDescription.ts] //// + +//// [arraySpliceParamDescription.ts] +// @target es5 + +export function isEmptyArr(l: { length: number }) { + return l.length === 0 +} + +var arrA : string[] +arrA = ["a", "b", "c", "d", "e", "f", "g"] + +// deleteCount param: undefined | NaN | 0 | -int; no elements removed +var undefSplice1 = arrA.splice(2, undefined) // OK +var charSplice1 = arrA.splice(2, "a") // expect error +var naNSplice1 = arrA.splice(2, NaN) // OK +var zeroSplice1 = arrA.splice(2, 0) // OK +var negSplice1 = arrA.splice(2, -2) // OK and expect arrA = ["a", "b", "c", "d", "e", "f", "g"] + +// deleteCount param omitted; All elements after start param are removed +var omitSplice1 = arrA.splice(2,) // OK expect arrA = ["a", "b"] + +// testing the splice arrays are empty +isEmptyArr(undefSplice1) // OK and true +isEmptyArr(charSplice1) // OK and true +isEmptyArr(naNSplice1) // OK and true +isEmptyArr(zeroSplice1) // OK and true +isEmptyArr(negSplice1) // OK and true +isEmptyArr(omitSplice1) // OK and false. length of removed elements is 5 + +var arrB : string[] +arrB = ["a", "b", "c", "d", "e", "f", "g"] + +var undefSplice2 = arrB.splice(2, undefined, "h", "i") // expect error and arrB = ["a", "b", "h", "i", "e", "f", "g"] +var omitSplice2 = arrB.splice(2, , "j", "k") // expect error and arrB = ["a", "b", "j", "k", "e", "f", "g"] +var naNSplice2 = arrB.splice(2, NaN, "l", "m") // OK and arrB = ["a", "b", "l", "m", "e", "f", "g"] +var charSplice2 = arrB.splice(2, "a", "n", "o") // expect error and arrB = ["a", "b", "n", "o", "e", "f", "g"] +var zeroSplice2 = arrB.splice(2, 0, "p", "q") // OK and arrB = ["a", "b", "p", "q", "e", "f", "g"] +var negSplice2 = arrB.splice(2, -2, "r", "s") // OK and arrB = ["a", "b", "r", "s", "e", "f", "g"] + +isEmptyArr(undefSplice2) // OK and true +isEmptyArr(omitSplice2) // OK and true +isEmptyArr(naNSplice2) // OK and true +isEmptyArr(charSplice2) // OK and true +isEmptyArr(zeroSplice2) // OK and true +isEmptyArr(negSplice2) // OK and true + +//// [arraySpliceParamDescription.js] +"use strict"; +// @target es5 +Object.defineProperty(exports, "__esModule", { value: true }); +exports.isEmptyArr = isEmptyArr; +function isEmptyArr(l) { + return l.length === 0; +} +var arrA; +arrA = ["a", "b", "c", "d", "e", "f", "g"]; +// deleteCount param: undefined | NaN | 0 | -int; no elements removed +var undefSplice1 = arrA.splice(2, undefined); // OK +var charSplice1 = arrA.splice(2, "a"); // expect error +var naNSplice1 = arrA.splice(2, NaN); // OK +var zeroSplice1 = arrA.splice(2, 0); // OK +var negSplice1 = arrA.splice(2, -2); // OK and expect arrA = ["a", "b", "c", "d", "e", "f", "g"] +// deleteCount param omitted; All elements after start param are removed +var omitSplice1 = arrA.splice(2); // OK expect arrA = ["a", "b"] +// testing the splice arrays are empty +isEmptyArr(undefSplice1); // OK and true +isEmptyArr(charSplice1); // OK and true +isEmptyArr(naNSplice1); // OK and true +isEmptyArr(zeroSplice1); // OK and true +isEmptyArr(negSplice1); // OK and true +isEmptyArr(omitSplice1); // OK and false. length of removed elements is 5 +var arrB; +arrB = ["a", "b", "c", "d", "e", "f", "g"]; +var undefSplice2 = arrB.splice(2, undefined, "h", "i"); // expect error and arrB = ["a", "b", "h", "i", "e", "f", "g"] +var omitSplice2 = arrB.splice(2, "j", "k"); // expect error and arrB = ["a", "b", "j", "k", "e", "f", "g"] +var naNSplice2 = arrB.splice(2, NaN, "l", "m"); // OK and arrB = ["a", "b", "l", "m", "e", "f", "g"] +var charSplice2 = arrB.splice(2, "a", "n", "o"); // expect error and arrB = ["a", "b", "n", "o", "e", "f", "g"] +var zeroSplice2 = arrB.splice(2, 0, "p", "q"); // OK and arrB = ["a", "b", "p", "q", "e", "f", "g"] +var negSplice2 = arrB.splice(2, -2, "r", "s"); // OK and arrB = ["a", "b", "r", "s", "e", "f", "g"] +isEmptyArr(undefSplice2); // OK and true +isEmptyArr(omitSplice2); // OK and true +isEmptyArr(naNSplice2); // OK and true +isEmptyArr(charSplice2); // OK and true +isEmptyArr(zeroSplice2); // OK and true +isEmptyArr(negSplice2); // OK and true diff --git a/tests/baselines/reference/arraySpliceParamDescription.symbols b/tests/baselines/reference/arraySpliceParamDescription.symbols new file mode 100644 index 0000000000000..642b052884f77 --- /dev/null +++ b/tests/baselines/reference/arraySpliceParamDescription.symbols @@ -0,0 +1,155 @@ +//// [tests/cases/compiler/arraySpliceParamDescription.ts] //// + +=== arraySpliceParamDescription.ts === +// @target es5 + +export function isEmptyArr(l: { length: number }) { +>isEmptyArr : Symbol(isEmptyArr, Decl(arraySpliceParamDescription.ts, 0, 0)) +>l : Symbol(l, Decl(arraySpliceParamDescription.ts, 2, 27)) +>length : Symbol(length, Decl(arraySpliceParamDescription.ts, 2, 31)) + + return l.length === 0 +>l.length : Symbol(length, Decl(arraySpliceParamDescription.ts, 2, 31)) +>l : Symbol(l, Decl(arraySpliceParamDescription.ts, 2, 27)) +>length : Symbol(length, Decl(arraySpliceParamDescription.ts, 2, 31)) +} + +var arrA : string[] +>arrA : Symbol(arrA, Decl(arraySpliceParamDescription.ts, 6, 3)) + +arrA = ["a", "b", "c", "d", "e", "f", "g"] +>arrA : Symbol(arrA, Decl(arraySpliceParamDescription.ts, 6, 3)) + +// deleteCount param: undefined | NaN | 0 | -int; no elements removed +var undefSplice1 = arrA.splice(2, undefined) // OK +>undefSplice1 : Symbol(undefSplice1, Decl(arraySpliceParamDescription.ts, 10, 3)) +>arrA.splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>arrA : Symbol(arrA, Decl(arraySpliceParamDescription.ts, 6, 3)) +>splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +var charSplice1 = arrA.splice(2, "a") // expect error +>charSplice1 : Symbol(charSplice1, Decl(arraySpliceParamDescription.ts, 11, 3)) +>arrA.splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>arrA : Symbol(arrA, Decl(arraySpliceParamDescription.ts, 6, 3)) +>splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + +var naNSplice1 = arrA.splice(2, NaN) // OK +>naNSplice1 : Symbol(naNSplice1, Decl(arraySpliceParamDescription.ts, 12, 3)) +>arrA.splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>arrA : Symbol(arrA, Decl(arraySpliceParamDescription.ts, 6, 3)) +>splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>NaN : Symbol(NaN, Decl(lib.es5.d.ts, --, --)) + +var zeroSplice1 = arrA.splice(2, 0) // OK +>zeroSplice1 : Symbol(zeroSplice1, Decl(arraySpliceParamDescription.ts, 13, 3)) +>arrA.splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>arrA : Symbol(arrA, Decl(arraySpliceParamDescription.ts, 6, 3)) +>splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + +var negSplice1 = arrA.splice(2, -2) // OK and expect arrA = ["a", "b", "c", "d", "e", "f", "g"] +>negSplice1 : Symbol(negSplice1, Decl(arraySpliceParamDescription.ts, 14, 3)) +>arrA.splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>arrA : Symbol(arrA, Decl(arraySpliceParamDescription.ts, 6, 3)) +>splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + +// deleteCount param omitted; All elements after start param are removed +var omitSplice1 = arrA.splice(2,) // OK expect arrA = ["a", "b"] +>omitSplice1 : Symbol(omitSplice1, Decl(arraySpliceParamDescription.ts, 17, 3)) +>arrA.splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>arrA : Symbol(arrA, Decl(arraySpliceParamDescription.ts, 6, 3)) +>splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + +// testing the splice arrays are empty +isEmptyArr(undefSplice1) // OK and true +>isEmptyArr : Symbol(isEmptyArr, Decl(arraySpliceParamDescription.ts, 0, 0)) +>undefSplice1 : Symbol(undefSplice1, Decl(arraySpliceParamDescription.ts, 10, 3)) + +isEmptyArr(charSplice1) // OK and true +>isEmptyArr : Symbol(isEmptyArr, Decl(arraySpliceParamDescription.ts, 0, 0)) +>charSplice1 : Symbol(charSplice1, Decl(arraySpliceParamDescription.ts, 11, 3)) + +isEmptyArr(naNSplice1) // OK and true +>isEmptyArr : Symbol(isEmptyArr, Decl(arraySpliceParamDescription.ts, 0, 0)) +>naNSplice1 : Symbol(naNSplice1, Decl(arraySpliceParamDescription.ts, 12, 3)) + +isEmptyArr(zeroSplice1) // OK and true +>isEmptyArr : Symbol(isEmptyArr, Decl(arraySpliceParamDescription.ts, 0, 0)) +>zeroSplice1 : Symbol(zeroSplice1, Decl(arraySpliceParamDescription.ts, 13, 3)) + +isEmptyArr(negSplice1) // OK and true +>isEmptyArr : Symbol(isEmptyArr, Decl(arraySpliceParamDescription.ts, 0, 0)) +>negSplice1 : Symbol(negSplice1, Decl(arraySpliceParamDescription.ts, 14, 3)) + +isEmptyArr(omitSplice1) // OK and false. length of removed elements is 5 +>isEmptyArr : Symbol(isEmptyArr, Decl(arraySpliceParamDescription.ts, 0, 0)) +>omitSplice1 : Symbol(omitSplice1, Decl(arraySpliceParamDescription.ts, 17, 3)) + +var arrB : string[] +>arrB : Symbol(arrB, Decl(arraySpliceParamDescription.ts, 27, 3)) + +arrB = ["a", "b", "c", "d", "e", "f", "g"] +>arrB : Symbol(arrB, Decl(arraySpliceParamDescription.ts, 27, 3)) + +var undefSplice2 = arrB.splice(2, undefined, "h", "i") // expect error and arrB = ["a", "b", "h", "i", "e", "f", "g"] +>undefSplice2 : Symbol(undefSplice2, Decl(arraySpliceParamDescription.ts, 30, 3)) +>arrB.splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>arrB : Symbol(arrB, Decl(arraySpliceParamDescription.ts, 27, 3)) +>splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>undefined : Symbol(undefined) + +var omitSplice2 = arrB.splice(2, , "j", "k") // expect error and arrB = ["a", "b", "j", "k", "e", "f", "g"] +>omitSplice2 : Symbol(omitSplice2, Decl(arraySpliceParamDescription.ts, 31, 3)) +>arrB.splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>arrB : Symbol(arrB, Decl(arraySpliceParamDescription.ts, 27, 3)) +>splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + +var naNSplice2 = arrB.splice(2, NaN, "l", "m") // OK and arrB = ["a", "b", "l", "m", "e", "f", "g"] +>naNSplice2 : Symbol(naNSplice2, Decl(arraySpliceParamDescription.ts, 32, 3)) +>arrB.splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>arrB : Symbol(arrB, Decl(arraySpliceParamDescription.ts, 27, 3)) +>splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>NaN : Symbol(NaN, Decl(lib.es5.d.ts, --, --)) + +var charSplice2 = arrB.splice(2, "a", "n", "o") // expect error and arrB = ["a", "b", "n", "o", "e", "f", "g"] +>charSplice2 : Symbol(charSplice2, Decl(arraySpliceParamDescription.ts, 33, 3)) +>arrB.splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>arrB : Symbol(arrB, Decl(arraySpliceParamDescription.ts, 27, 3)) +>splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + +var zeroSplice2 = arrB.splice(2, 0, "p", "q") // OK and arrB = ["a", "b", "p", "q", "e", "f", "g"] +>zeroSplice2 : Symbol(zeroSplice2, Decl(arraySpliceParamDescription.ts, 34, 3)) +>arrB.splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>arrB : Symbol(arrB, Decl(arraySpliceParamDescription.ts, 27, 3)) +>splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + +var negSplice2 = arrB.splice(2, -2, "r", "s") // OK and arrB = ["a", "b", "r", "s", "e", "f", "g"] +>negSplice2 : Symbol(negSplice2, Decl(arraySpliceParamDescription.ts, 35, 3)) +>arrB.splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>arrB : Symbol(arrB, Decl(arraySpliceParamDescription.ts, 27, 3)) +>splice : Symbol(Array.splice, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + +isEmptyArr(undefSplice2) // OK and true +>isEmptyArr : Symbol(isEmptyArr, Decl(arraySpliceParamDescription.ts, 0, 0)) +>undefSplice2 : Symbol(undefSplice2, Decl(arraySpliceParamDescription.ts, 30, 3)) + +isEmptyArr(omitSplice2) // OK and true +>isEmptyArr : Symbol(isEmptyArr, Decl(arraySpliceParamDescription.ts, 0, 0)) +>omitSplice2 : Symbol(omitSplice2, Decl(arraySpliceParamDescription.ts, 31, 3)) + +isEmptyArr(naNSplice2) // OK and true +>isEmptyArr : Symbol(isEmptyArr, Decl(arraySpliceParamDescription.ts, 0, 0)) +>naNSplice2 : Symbol(naNSplice2, Decl(arraySpliceParamDescription.ts, 32, 3)) + +isEmptyArr(charSplice2) // OK and true +>isEmptyArr : Symbol(isEmptyArr, Decl(arraySpliceParamDescription.ts, 0, 0)) +>charSplice2 : Symbol(charSplice2, Decl(arraySpliceParamDescription.ts, 33, 3)) + +isEmptyArr(zeroSplice2) // OK and true +>isEmptyArr : Symbol(isEmptyArr, Decl(arraySpliceParamDescription.ts, 0, 0)) +>zeroSplice2 : Symbol(zeroSplice2, Decl(arraySpliceParamDescription.ts, 34, 3)) + +isEmptyArr(negSplice2) // OK and true +>isEmptyArr : Symbol(isEmptyArr, Decl(arraySpliceParamDescription.ts, 0, 0)) +>negSplice2 : Symbol(negSplice2, Decl(arraySpliceParamDescription.ts, 35, 3)) + diff --git a/tests/baselines/reference/arraySpliceParamDescription.types b/tests/baselines/reference/arraySpliceParamDescription.types new file mode 100644 index 0000000000000..3bd91cc895df7 --- /dev/null +++ b/tests/baselines/reference/arraySpliceParamDescription.types @@ -0,0 +1,393 @@ +//// [tests/cases/compiler/arraySpliceParamDescription.ts] //// + +=== arraySpliceParamDescription.ts === +// @target es5 + +export function isEmptyArr(l: { length: number }) { +>isEmptyArr : (l: { length: number; }) => boolean +> : ^ ^^ ^^^^^^^^^^^^ +>l : { length: number; } +> : ^^^^^^^^^^ ^^^ +>length : number +> : ^^^^^^ + + return l.length === 0 +>l.length === 0 : boolean +> : ^^^^^^^ +>l.length : number +> : ^^^^^^ +>l : { length: number; } +> : ^^^^^^^^^^ ^^^ +>length : number +> : ^^^^^^ +>0 : 0 +> : ^ +} + +var arrA : string[] +>arrA : string[] +> : ^^^^^^^^ + +arrA = ["a", "b", "c", "d", "e", "f", "g"] +>arrA = ["a", "b", "c", "d", "e", "f", "g"] : string[] +> : ^^^^^^^^ +>arrA : string[] +> : ^^^^^^^^ +>["a", "b", "c", "d", "e", "f", "g"] : string[] +> : ^^^^^^^^ +>"a" : "a" +> : ^^^ +>"b" : "b" +> : ^^^ +>"c" : "c" +> : ^^^ +>"d" : "d" +> : ^^^ +>"e" : "e" +> : ^^^ +>"f" : "f" +> : ^^^ +>"g" : "g" +> : ^^^ + +// deleteCount param: undefined | NaN | 0 | -int; no elements removed +var undefSplice1 = arrA.splice(2, undefined) // OK +>undefSplice1 : string[] +> : ^^^^^^^^ +>arrA.splice(2, undefined) : string[] +> : ^^^^^^^^ +>arrA.splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } +> : ^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>arrA : string[] +> : ^^^^^^^^ +>splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } +> : ^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>2 : 2 +> : ^ +>undefined : undefined +> : ^^^^^^^^^ + +var charSplice1 = arrA.splice(2, "a") // expect error +>charSplice1 : string[] +> : ^^^^^^^^ +>arrA.splice(2, "a") : string[] +> : ^^^^^^^^ +>arrA.splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } +> : ^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>arrA : string[] +> : ^^^^^^^^ +>splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } +> : ^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>2 : 2 +> : ^ +>"a" : "a" +> : ^^^ + +var naNSplice1 = arrA.splice(2, NaN) // OK +>naNSplice1 : string[] +> : ^^^^^^^^ +>arrA.splice(2, NaN) : string[] +> : ^^^^^^^^ +>arrA.splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } +> : ^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>arrA : string[] +> : ^^^^^^^^ +>splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } +> : ^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>2 : 2 +> : ^ +>NaN : number +> : ^^^^^^ + +var zeroSplice1 = arrA.splice(2, 0) // OK +>zeroSplice1 : string[] +> : ^^^^^^^^ +>arrA.splice(2, 0) : string[] +> : ^^^^^^^^ +>arrA.splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } +> : ^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>arrA : string[] +> : ^^^^^^^^ +>splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } +> : ^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>2 : 2 +> : ^ +>0 : 0 +> : ^ + +var negSplice1 = arrA.splice(2, -2) // OK and expect arrA = ["a", "b", "c", "d", "e", "f", "g"] +>negSplice1 : string[] +> : ^^^^^^^^ +>arrA.splice(2, -2) : string[] +> : ^^^^^^^^ +>arrA.splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } +> : ^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>arrA : string[] +> : ^^^^^^^^ +>splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } +> : ^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>2 : 2 +> : ^ +>-2 : -2 +> : ^^ +>2 : 2 +> : ^ + +// deleteCount param omitted; All elements after start param are removed +var omitSplice1 = arrA.splice(2,) // OK expect arrA = ["a", "b"] +>omitSplice1 : string[] +> : ^^^^^^^^ +>arrA.splice(2,) : string[] +> : ^^^^^^^^ +>arrA.splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } +> : ^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>arrA : string[] +> : ^^^^^^^^ +>splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } +> : ^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>2 : 2 +> : ^ + +// testing the splice arrays are empty +isEmptyArr(undefSplice1) // OK and true +>isEmptyArr(undefSplice1) : boolean +> : ^^^^^^^ +>isEmptyArr : (l: { length: number; }) => boolean +> : ^ ^^ ^^^^^^^^^^^^ +>undefSplice1 : string[] +> : ^^^^^^^^ + +isEmptyArr(charSplice1) // OK and true +>isEmptyArr(charSplice1) : boolean +> : ^^^^^^^ +>isEmptyArr : (l: { length: number; }) => boolean +> : ^ ^^ ^^^^^^^^^^^^ +>charSplice1 : string[] +> : ^^^^^^^^ + +isEmptyArr(naNSplice1) // OK and true +>isEmptyArr(naNSplice1) : boolean +> : ^^^^^^^ +>isEmptyArr : (l: { length: number; }) => boolean +> : ^ ^^ ^^^^^^^^^^^^ +>naNSplice1 : string[] +> : ^^^^^^^^ + +isEmptyArr(zeroSplice1) // OK and true +>isEmptyArr(zeroSplice1) : boolean +> : ^^^^^^^ +>isEmptyArr : (l: { length: number; }) => boolean +> : ^ ^^ ^^^^^^^^^^^^ +>zeroSplice1 : string[] +> : ^^^^^^^^ + +isEmptyArr(negSplice1) // OK and true +>isEmptyArr(negSplice1) : boolean +> : ^^^^^^^ +>isEmptyArr : (l: { length: number; }) => boolean +> : ^ ^^ ^^^^^^^^^^^^ +>negSplice1 : string[] +> : ^^^^^^^^ + +isEmptyArr(omitSplice1) // OK and false. length of removed elements is 5 +>isEmptyArr(omitSplice1) : boolean +> : ^^^^^^^ +>isEmptyArr : (l: { length: number; }) => boolean +> : ^ ^^ ^^^^^^^^^^^^ +>omitSplice1 : string[] +> : ^^^^^^^^ + +var arrB : string[] +>arrB : string[] +> : ^^^^^^^^ + +arrB = ["a", "b", "c", "d", "e", "f", "g"] +>arrB = ["a", "b", "c", "d", "e", "f", "g"] : string[] +> : ^^^^^^^^ +>arrB : string[] +> : ^^^^^^^^ +>["a", "b", "c", "d", "e", "f", "g"] : string[] +> : ^^^^^^^^ +>"a" : "a" +> : ^^^ +>"b" : "b" +> : ^^^ +>"c" : "c" +> : ^^^ +>"d" : "d" +> : ^^^ +>"e" : "e" +> : ^^^ +>"f" : "f" +> : ^^^ +>"g" : "g" +> : ^^^ + +var undefSplice2 = arrB.splice(2, undefined, "h", "i") // expect error and arrB = ["a", "b", "h", "i", "e", "f", "g"] +>undefSplice2 : string[] +> : ^^^^^^^^ +>arrB.splice(2, undefined, "h", "i") : string[] +> : ^^^^^^^^ +>arrB.splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } +> : ^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>arrB : string[] +> : ^^^^^^^^ +>splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } +> : ^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>2 : 2 +> : ^ +>undefined : undefined +> : ^^^^^^^^^ +>"h" : "h" +> : ^^^ +>"i" : "i" +> : ^^^ + +var omitSplice2 = arrB.splice(2, , "j", "k") // expect error and arrB = ["a", "b", "j", "k", "e", "f", "g"] +>omitSplice2 : string[] +> : ^^^^^^^^ +>arrB.splice(2, , "j", "k") : string[] +> : ^^^^^^^^ +>arrB.splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } +> : ^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>arrB : string[] +> : ^^^^^^^^ +>splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } +> : ^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>2 : 2 +> : ^ +>"j" : "j" +> : ^^^ +>"k" : "k" +> : ^^^ + +var naNSplice2 = arrB.splice(2, NaN, "l", "m") // OK and arrB = ["a", "b", "l", "m", "e", "f", "g"] +>naNSplice2 : string[] +> : ^^^^^^^^ +>arrB.splice(2, NaN, "l", "m") : string[] +> : ^^^^^^^^ +>arrB.splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } +> : ^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>arrB : string[] +> : ^^^^^^^^ +>splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } +> : ^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>2 : 2 +> : ^ +>NaN : number +> : ^^^^^^ +>"l" : "l" +> : ^^^ +>"m" : "m" +> : ^^^ + +var charSplice2 = arrB.splice(2, "a", "n", "o") // expect error and arrB = ["a", "b", "n", "o", "e", "f", "g"] +>charSplice2 : string[] +> : ^^^^^^^^ +>arrB.splice(2, "a", "n", "o") : string[] +> : ^^^^^^^^ +>arrB.splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } +> : ^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>arrB : string[] +> : ^^^^^^^^ +>splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } +> : ^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>2 : 2 +> : ^ +>"a" : "a" +> : ^^^ +>"n" : "n" +> : ^^^ +>"o" : "o" +> : ^^^ + +var zeroSplice2 = arrB.splice(2, 0, "p", "q") // OK and arrB = ["a", "b", "p", "q", "e", "f", "g"] +>zeroSplice2 : string[] +> : ^^^^^^^^ +>arrB.splice(2, 0, "p", "q") : string[] +> : ^^^^^^^^ +>arrB.splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } +> : ^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>arrB : string[] +> : ^^^^^^^^ +>splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } +> : ^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>2 : 2 +> : ^ +>0 : 0 +> : ^ +>"p" : "p" +> : ^^^ +>"q" : "q" +> : ^^^ + +var negSplice2 = arrB.splice(2, -2, "r", "s") // OK and arrB = ["a", "b", "r", "s", "e", "f", "g"] +>negSplice2 : string[] +> : ^^^^^^^^ +>arrB.splice(2, -2, "r", "s") : string[] +> : ^^^^^^^^ +>arrB.splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } +> : ^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>arrB : string[] +> : ^^^^^^^^ +>splice : { (start: number, deleteCount?: number): string[]; (start: number, deleteCount: number, ...items: string[]): string[]; } +> : ^^^ ^^ ^^ ^^^ ^^^^^^^^^^^^^^ ^^ ^^ ^^ ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ +>2 : 2 +> : ^ +>-2 : -2 +> : ^^ +>2 : 2 +> : ^ +>"r" : "r" +> : ^^^ +>"s" : "s" +> : ^^^ + +isEmptyArr(undefSplice2) // OK and true +>isEmptyArr(undefSplice2) : boolean +> : ^^^^^^^ +>isEmptyArr : (l: { length: number; }) => boolean +> : ^ ^^ ^^^^^^^^^^^^ +>undefSplice2 : string[] +> : ^^^^^^^^ + +isEmptyArr(omitSplice2) // OK and true +>isEmptyArr(omitSplice2) : boolean +> : ^^^^^^^ +>isEmptyArr : (l: { length: number; }) => boolean +> : ^ ^^ ^^^^^^^^^^^^ +>omitSplice2 : string[] +> : ^^^^^^^^ + +isEmptyArr(naNSplice2) // OK and true +>isEmptyArr(naNSplice2) : boolean +> : ^^^^^^^ +>isEmptyArr : (l: { length: number; }) => boolean +> : ^ ^^ ^^^^^^^^^^^^ +>naNSplice2 : string[] +> : ^^^^^^^^ + +isEmptyArr(charSplice2) // OK and true +>isEmptyArr(charSplice2) : boolean +> : ^^^^^^^ +>isEmptyArr : (l: { length: number; }) => boolean +> : ^ ^^ ^^^^^^^^^^^^ +>charSplice2 : string[] +> : ^^^^^^^^ + +isEmptyArr(zeroSplice2) // OK and true +>isEmptyArr(zeroSplice2) : boolean +> : ^^^^^^^ +>isEmptyArr : (l: { length: number; }) => boolean +> : ^ ^^ ^^^^^^^^^^^^ +>zeroSplice2 : string[] +> : ^^^^^^^^ + +isEmptyArr(negSplice2) // OK and true +>isEmptyArr(negSplice2) : boolean +> : ^^^^^^^ +>isEmptyArr : (l: { length: number; }) => boolean +> : ^ ^^ ^^^^^^^^^^^^ +>negSplice2 : string[] +> : ^^^^^^^^ + diff --git a/tests/baselines/reference/arraySpliceSignatureHelp.baseline b/tests/baselines/reference/arraySpliceSignatureHelp.baseline new file mode 100644 index 0000000000000..cae15222f83e6 --- /dev/null +++ b/tests/baselines/reference/arraySpliceSignatureHelp.baseline @@ -0,0 +1,830 @@ +// === SignatureHelp === +=== /tests/cases/fourslash/file1.ts === +// [].splice( +// ^ +// | ---------------------------------------------------------------------- +// | splice(**start: number**, deleteCount?: number): any[] +// | Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. +// | @param start The zero-based location in the array from which to start removing elements. +// | @param deleteCount The number of elements to remove. Omitting this argument will remove all elements from the start +// | paramater location to end of the array. If value of this argument is either a negative number, zero, undefined, or a type +// | that cannot be coverted to an integer, the function will evaluate the argument as zero and not remove any elements. +// | @returns An array containing the elements that were deleted. +// | ---------------------------------------------------------------------- +// [].splice(2, 0, +// ^ +// | ---------------------------------------------------------------------- +// | splice(start: number, deleteCount: number, **...items: any[]**): any[] +// | Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. +// | @param start The zero-based location in the array from which to start removing elements. +// | @param deleteCount The number of elements to remove. If value of this argument is either a negative number, zero, +// | undefined, or a type that cannot be coverted to an integer, the function will evaluate the argument as zero and +// | not remove any elements. +// | Note: If the deleteCount argument is left empty between the start and items arguments, it will not be evaluated as +// | an omission. Instead, it will be evaluated as undefined, which will be evaluated as zero. +// | @param items Elements to insert into the array in place of the deleted elements. +// | @returns An array containing the elements that were deleted. +// | ---------------------------------------------------------------------- + +[ + { + "marker": { + "fileName": "/tests/cases/fourslash/file1.ts", + "position": 10, + "name": "1" + }, + "item": { + "items": [ + { + "isVariadic": false, + "prefixDisplayParts": [ + { + "text": "splice", + "kind": "methodName" + }, + { + "text": "(", + "kind": "punctuation" + } + ], + "suffixDisplayParts": [ + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "any", + "kind": "keyword" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "]", + "kind": "punctuation" + } + ], + "separatorDisplayParts": [ + { + "text": ",", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + } + ], + "parameters": [ + { + "name": "start", + "documentation": [ + { + "text": "The zero-based location in the array from which to start removing elements.", + "kind": "text" + } + ], + "displayParts": [ + { + "text": "start", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "isOptional": false, + "isRest": false + }, + { + "name": "deleteCount", + "documentation": [ + { + "text": "The number of elements to remove. Omitting this argument will remove all elements from the start \nparamater location to end of the array. If value of this argument is either a negative number, zero, undefined, or a type \nthat cannot be coverted to an integer, the function will evaluate the argument as zero and not remove any elements.", + "kind": "text" + } + ], + "displayParts": [ + { + "text": "deleteCount", + "kind": "parameterName" + }, + { + "text": "?", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "isOptional": true, + "isRest": false + } + ], + "documentation": [ + { + "text": "Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "start", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "The zero-based location in the array from which to start removing elements.", + "kind": "text" + } + ] + }, + { + "name": "param", + "text": [ + { + "text": "deleteCount", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "The number of elements to remove. Omitting this argument will remove all elements from the start \nparamater location to end of the array. If value of this argument is either a negative number, zero, undefined, or a type \nthat cannot be coverted to an integer, the function will evaluate the argument as zero and not remove any elements.", + "kind": "text" + } + ] + }, + { + "name": "returns", + "text": [ + { + "text": "An array containing the elements that were deleted.", + "kind": "text" + } + ] + } + ] + }, + { + "isVariadic": true, + "prefixDisplayParts": [ + { + "text": "splice", + "kind": "methodName" + }, + { + "text": "(", + "kind": "punctuation" + } + ], + "suffixDisplayParts": [ + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "any", + "kind": "keyword" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "]", + "kind": "punctuation" + } + ], + "separatorDisplayParts": [ + { + "text": ",", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + } + ], + "parameters": [ + { + "name": "start", + "documentation": [ + { + "text": "The zero-based location in the array from which to start removing elements.", + "kind": "text" + } + ], + "displayParts": [ + { + "text": "start", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "isOptional": false, + "isRest": false + }, + { + "name": "deleteCount", + "documentation": [ + { + "text": "The number of elements to remove. If value of this argument is either a negative number, zero,\nundefined, or a type that cannot be coverted to an integer, the function will evaluate the argument as zero and \nnot remove any elements. \nNote: If the deleteCount argument is left empty between the start and items arguments, it will not be evaluated as \nan omission. Instead, it will be evaluated as undefined, which will be evaluated as zero.", + "kind": "text" + } + ], + "displayParts": [ + { + "text": "deleteCount", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "isOptional": false, + "isRest": false + }, + { + "name": "items", + "documentation": [ + { + "text": "Elements to insert into the array in place of the deleted elements.", + "kind": "text" + } + ], + "displayParts": [ + { + "text": "...", + "kind": "punctuation" + }, + { + "text": "items", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "any", + "kind": "keyword" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "]", + "kind": "punctuation" + } + ], + "isOptional": false, + "isRest": false + } + ], + "documentation": [ + { + "text": "Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "start", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "The zero-based location in the array from which to start removing elements.", + "kind": "text" + } + ] + }, + { + "name": "param", + "text": [ + { + "text": "deleteCount", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "The number of elements to remove. If value of this argument is either a negative number, zero,\nundefined, or a type that cannot be coverted to an integer, the function will evaluate the argument as zero and \nnot remove any elements. \nNote: If the deleteCount argument is left empty between the start and items arguments, it will not be evaluated as \nan omission. Instead, it will be evaluated as undefined, which will be evaluated as zero.", + "kind": "text" + } + ] + }, + { + "name": "param", + "text": [ + { + "text": "items", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Elements to insert into the array in place of the deleted elements.", + "kind": "text" + } + ] + }, + { + "name": "returns", + "text": [ + { + "text": "An array containing the elements that were deleted.", + "kind": "text" + } + ] + } + ] + } + ], + "applicableSpan": { + "start": 10, + "length": 17 + }, + "selectedItemIndex": 0, + "argumentIndex": 0, + "argumentCount": 1 + } + }, + { + "marker": { + "fileName": "/tests/cases/fourslash/file1.ts", + "position": 27, + "name": "2" + }, + "item": { + "items": [ + { + "isVariadic": false, + "prefixDisplayParts": [ + { + "text": "splice", + "kind": "methodName" + }, + { + "text": "(", + "kind": "punctuation" + } + ], + "suffixDisplayParts": [ + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "any", + "kind": "keyword" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "]", + "kind": "punctuation" + } + ], + "separatorDisplayParts": [ + { + "text": ",", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + } + ], + "parameters": [ + { + "name": "start", + "documentation": [ + { + "text": "The zero-based location in the array from which to start removing elements.", + "kind": "text" + } + ], + "displayParts": [ + { + "text": "start", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "isOptional": false, + "isRest": false + }, + { + "name": "deleteCount", + "documentation": [ + { + "text": "The number of elements to remove. Omitting this argument will remove all elements from the start \nparamater location to end of the array. If value of this argument is either a negative number, zero, undefined, or a type \nthat cannot be coverted to an integer, the function will evaluate the argument as zero and not remove any elements.", + "kind": "text" + } + ], + "displayParts": [ + { + "text": "deleteCount", + "kind": "parameterName" + }, + { + "text": "?", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "isOptional": true, + "isRest": false + } + ], + "documentation": [ + { + "text": "Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "start", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "The zero-based location in the array from which to start removing elements.", + "kind": "text" + } + ] + }, + { + "name": "param", + "text": [ + { + "text": "deleteCount", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "The number of elements to remove. Omitting this argument will remove all elements from the start \nparamater location to end of the array. If value of this argument is either a negative number, zero, undefined, or a type \nthat cannot be coverted to an integer, the function will evaluate the argument as zero and not remove any elements.", + "kind": "text" + } + ] + }, + { + "name": "returns", + "text": [ + { + "text": "An array containing the elements that were deleted.", + "kind": "text" + } + ] + } + ] + }, + { + "isVariadic": true, + "prefixDisplayParts": [ + { + "text": "splice", + "kind": "methodName" + }, + { + "text": "(", + "kind": "punctuation" + } + ], + "suffixDisplayParts": [ + { + "text": ")", + "kind": "punctuation" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "any", + "kind": "keyword" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "]", + "kind": "punctuation" + } + ], + "separatorDisplayParts": [ + { + "text": ",", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + } + ], + "parameters": [ + { + "name": "start", + "documentation": [ + { + "text": "The zero-based location in the array from which to start removing elements.", + "kind": "text" + } + ], + "displayParts": [ + { + "text": "start", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "isOptional": false, + "isRest": false + }, + { + "name": "deleteCount", + "documentation": [ + { + "text": "The number of elements to remove. If value of this argument is either a negative number, zero,\nundefined, or a type that cannot be coverted to an integer, the function will evaluate the argument as zero and \nnot remove any elements. \nNote: If the deleteCount argument is left empty between the start and items arguments, it will not be evaluated as \nan omission. Instead, it will be evaluated as undefined, which will be evaluated as zero.", + "kind": "text" + } + ], + "displayParts": [ + { + "text": "deleteCount", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "number", + "kind": "keyword" + } + ], + "isOptional": false, + "isRest": false + }, + { + "name": "items", + "documentation": [ + { + "text": "Elements to insert into the array in place of the deleted elements.", + "kind": "text" + } + ], + "displayParts": [ + { + "text": "...", + "kind": "punctuation" + }, + { + "text": "items", + "kind": "parameterName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "any", + "kind": "keyword" + }, + { + "text": "[", + "kind": "punctuation" + }, + { + "text": "]", + "kind": "punctuation" + } + ], + "isOptional": false, + "isRest": false + } + ], + "documentation": [ + { + "text": "Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.", + "kind": "text" + } + ], + "tags": [ + { + "name": "param", + "text": [ + { + "text": "start", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "The zero-based location in the array from which to start removing elements.", + "kind": "text" + } + ] + }, + { + "name": "param", + "text": [ + { + "text": "deleteCount", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "The number of elements to remove. If value of this argument is either a negative number, zero,\nundefined, or a type that cannot be coverted to an integer, the function will evaluate the argument as zero and \nnot remove any elements. \nNote: If the deleteCount argument is left empty between the start and items arguments, it will not be evaluated as \nan omission. Instead, it will be evaluated as undefined, which will be evaluated as zero.", + "kind": "text" + } + ] + }, + { + "name": "param", + "text": [ + { + "text": "items", + "kind": "parameterName" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "Elements to insert into the array in place of the deleted elements.", + "kind": "text" + } + ] + }, + { + "name": "returns", + "text": [ + { + "text": "An array containing the elements that were deleted.", + "kind": "text" + } + ] + } + ] + } + ], + "applicableSpan": { + "start": 21, + "length": 6 + }, + "selectedItemIndex": 1, + "argumentIndex": 2, + "argumentCount": 3 + } + } +] \ No newline at end of file diff --git a/tests/baselines/reference/completionEntryForUnionMethod.baseline b/tests/baselines/reference/completionEntryForUnionMethod.baseline index 4a503b4a10a4c..0c0fddaf1071f 100644 --- a/tests/baselines/reference/completionEntryForUnionMethod.baseline +++ b/tests/baselines/reference/completionEntryForUnionMethod.baseline @@ -4404,7 +4404,7 @@ "kind": "space" }, { - "text": "The number of elements to remove.", + "text": "The number of elements to remove. Omitting this argument will remove all elements from the start \nparamater location to end of the array. If value of this argument is either a negative number, zero, undefined, or a type \nthat cannot be coverted to an integer, the function will evaluate the argument as zero and not remove any elements.", "kind": "text" } ] diff --git a/tests/baselines/reference/goToTypeDefinition_arrayType.baseline.jsonc b/tests/baselines/reference/goToTypeDefinition_arrayType.baseline.jsonc index bb25003a8fc5a..ad7182f4ca179 100644 --- a/tests/baselines/reference/goToTypeDefinition_arrayType.baseline.jsonc +++ b/tests/baselines/reference/goToTypeDefinition_arrayType.baseline.jsonc @@ -87,14 +87,20 @@ // /** // * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. // * @param start The zero-based location in the array from which to start removing elements. -// * @param deleteCount The number of elements to remove. +// * @param deleteCount The number of elements to remove. Omitting this argument will remove all elements from the start +// * paramater location to end of the array. If value of this argument is either a negative number, zero, undefined, or a type +// * that cannot be coverted to an integer, the function will evaluate the argument as zero and not remove any elements. // * @returns An array containing the elements that were deleted. // */ // splice(start: number, deleteCount?: number): T[]; // /** // * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. // * @param start The zero-based location in the array from which to start removing elements. -// * @param deleteCount The number of elements to remove. +// * @param deleteCount The number of elements to remove. If value of this argument is either a negative number, zero, +// * undefined, or a type that cannot be coverted to an integer, the function will evaluate the argument as zero and +// * not remove any elements. +// * Note: If the deleteCount argument is left empty between the start and items arguments, it will not be evaluated as +// * an omission. Instead, it will be evaluated as undefined, which will be evaluated as zero. // * @param items Elements to insert into the array in place of the deleted elements. // * @returns An array containing the elements that were deleted. // */ @@ -340,14 +346,20 @@ // /** // * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. // * @param start The zero-based location in the array from which to start removing elements. -// * @param deleteCount The number of elements to remove. +// * @param deleteCount The number of elements to remove. Omitting this argument will remove all elements from the start +// * paramater location to end of the array. If value of this argument is either a negative number, zero, undefined, or a type +// * that cannot be coverted to an integer, the function will evaluate the argument as zero and not remove any elements. // * @returns An array containing the elements that were deleted. // */ // splice(start: number, deleteCount?: number): T[]; // /** // * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. // * @param start The zero-based location in the array from which to start removing elements. -// * @param deleteCount The number of elements to remove. +// * @param deleteCount The number of elements to remove. If value of this argument is either a negative number, zero, +// * undefined, or a type that cannot be coverted to an integer, the function will evaluate the argument as zero and +// * not remove any elements. +// * Note: If the deleteCount argument is left empty between the start and items arguments, it will not be evaluated as +// * an omission. Instead, it will be evaluated as undefined, which will be evaluated as zero. // * @param items Elements to insert into the array in place of the deleted elements. // * @returns An array containing the elements that were deleted. // */ diff --git a/tests/cases/compiler/arraySpliceParamDescription.ts b/tests/cases/compiler/arraySpliceParamDescription.ts new file mode 100644 index 0000000000000..c82655cae66e4 --- /dev/null +++ b/tests/cases/compiler/arraySpliceParamDescription.ts @@ -0,0 +1,43 @@ +// @target es5 + +export function isEmptyArr(l: { length: number }) { + return l.length === 0 +} + +var arrA : string[] +arrA = ["a", "b", "c", "d", "e", "f", "g"] + +// deleteCount param: undefined | NaN | 0 | -int; no elements removed +var undefSplice1 = arrA.splice(2, undefined) // OK +var charSplice1 = arrA.splice(2, "a") // expect error +var naNSplice1 = arrA.splice(2, NaN) // OK +var zeroSplice1 = arrA.splice(2, 0) // OK +var negSplice1 = arrA.splice(2, -2) // OK and expect arrA = ["a", "b", "c", "d", "e", "f", "g"] + +// deleteCount param omitted; All elements after start param are removed +var omitSplice1 = arrA.splice(2,) // OK expect arrA = ["a", "b"] + +// testing the splice arrays are empty +isEmptyArr(undefSplice1) // OK and true +isEmptyArr(charSplice1) // OK and true +isEmptyArr(naNSplice1) // OK and true +isEmptyArr(zeroSplice1) // OK and true +isEmptyArr(negSplice1) // OK and true +isEmptyArr(omitSplice1) // OK and false. length of removed elements is 5 + +var arrB : string[] +arrB = ["a", "b", "c", "d", "e", "f", "g"] + +var undefSplice2 = arrB.splice(2, undefined, "h", "i") // expect error and arrB = ["a", "b", "h", "i", "e", "f", "g"] +var omitSplice2 = arrB.splice(2, , "j", "k") // expect error and arrB = ["a", "b", "j", "k", "e", "f", "g"] +var naNSplice2 = arrB.splice(2, NaN, "l", "m") // OK and arrB = ["a", "b", "l", "m", "e", "f", "g"] +var charSplice2 = arrB.splice(2, "a", "n", "o") // expect error and arrB = ["a", "b", "n", "o", "e", "f", "g"] +var zeroSplice2 = arrB.splice(2, 0, "p", "q") // OK and arrB = ["a", "b", "p", "q", "e", "f", "g"] +var negSplice2 = arrB.splice(2, -2, "r", "s") // OK and arrB = ["a", "b", "r", "s", "e", "f", "g"] + +isEmptyArr(undefSplice2) // OK and true +isEmptyArr(omitSplice2) // OK and true +isEmptyArr(naNSplice2) // OK and true +isEmptyArr(charSplice2) // OK and true +isEmptyArr(zeroSplice2) // OK and true +isEmptyArr(negSplice2) // OK and true \ No newline at end of file diff --git a/tests/cases/fourslash/arraySpliceSignatureHelp.ts b/tests/cases/fourslash/arraySpliceSignatureHelp.ts new file mode 100644 index 0000000000000..47394b85bfcc6 --- /dev/null +++ b/tests/cases/fourslash/arraySpliceSignatureHelp.ts @@ -0,0 +1,10 @@ +/// + +// @Target: ES5 + +// @Filename: file1.ts +//// [].splice(/*1*/ +//// [].splice(2, 0, /*2*/ + +goTo.file("file1.ts"); +verify.baselineSignatureHelp(); \ No newline at end of file From bc5fa06f6fbf1dcfae5689e86bf9dc1919048d80 Mon Sep 17 00:00:00 2001 From: JulianTaub Date: Tue, 18 Feb 2025 23:43:35 -0500 Subject: [PATCH 4/5] Formats lib/es5.d.ts --- src/lib/es5.d.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index d499e3a684154..50465eae82c73 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1375,9 +1375,9 @@ interface Array { /** * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. - * @param deleteCount The number of elements to remove. Omitting this argument will remove all elements from the start - * paramater location to end of the array. If value of this argument is either a negative number, zero, undefined, or a type - * that cannot be coverted to an integer, the function will evaluate the argument as zero and not remove any elements. + * @param deleteCount The number of elements to remove. Omitting this argument will remove all elements from the start + * paramater location to end of the array. If value of this argument is either a negative number, zero, undefined, or a type + * that cannot be coverted to an integer, the function will evaluate the argument as zero and not remove any elements. * @returns An array containing the elements that were deleted. */ splice(start: number, deleteCount?: number): T[]; @@ -1385,10 +1385,10 @@ interface Array { * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. * @param start The zero-based location in the array from which to start removing elements. * @param deleteCount The number of elements to remove. If value of this argument is either a negative number, zero, - * undefined, or a type that cannot be coverted to an integer, the function will evaluate the argument as zero and - * not remove any elements. - * Note: If the deleteCount argument is left empty between the start and items arguments, it will not be evaluated as - * an omission. Instead, it will be evaluated as undefined, which will be evaluated as zero. + * undefined, or a type that cannot be coverted to an integer, the function will evaluate the argument as zero and + * not remove any elements. + * Note: If the deleteCount argument is left empty between the start and items arguments, it will not be evaluated as + * an omission. Instead, it will be evaluated as undefined, which will be evaluated as zero. * @param items Elements to insert into the array in place of the deleted elements. * @returns An array containing the elements that were deleted. */ From 6d234481c500173e29ad3317a6c94becc2d4c7db Mon Sep 17 00:00:00 2001 From: JulianTaub Date: Fri, 21 Feb 2025 18:01:53 -0500 Subject: [PATCH 5/5] Adds reformatted baseline tests to refrence --- .../arraySpliceSignatureHelp.baseline | 26 ++++++++--------- .../completionEntryForUnionMethod.baseline | 2 +- ...oToTypeDefinition_arrayType.baseline.jsonc | 28 +++++++++---------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/tests/baselines/reference/arraySpliceSignatureHelp.baseline b/tests/baselines/reference/arraySpliceSignatureHelp.baseline index cae15222f83e6..80eb83b25d037 100644 --- a/tests/baselines/reference/arraySpliceSignatureHelp.baseline +++ b/tests/baselines/reference/arraySpliceSignatureHelp.baseline @@ -6,8 +6,8 @@ // | splice(**start: number**, deleteCount?: number): any[] // | Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. // | @param start The zero-based location in the array from which to start removing elements. -// | @param deleteCount The number of elements to remove. Omitting this argument will remove all elements from the start -// | paramater location to end of the array. If value of this argument is either a negative number, zero, undefined, or a type +// | @param deleteCount The number of elements to remove. Omitting this argument will remove all elements from the start +// | paramater location to end of the array. If value of this argument is either a negative number, zero, undefined, or a type // | that cannot be coverted to an integer, the function will evaluate the argument as zero and not remove any elements. // | @returns An array containing the elements that were deleted. // | ---------------------------------------------------------------------- @@ -18,9 +18,9 @@ // | Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. // | @param start The zero-based location in the array from which to start removing elements. // | @param deleteCount The number of elements to remove. If value of this argument is either a negative number, zero, -// | undefined, or a type that cannot be coverted to an integer, the function will evaluate the argument as zero and -// | not remove any elements. -// | Note: If the deleteCount argument is left empty between the start and items arguments, it will not be evaluated as +// | undefined, or a type that cannot be coverted to an integer, the function will evaluate the argument as zero and +// | not remove any elements. +// | Note: If the deleteCount argument is left empty between the start and items arguments, it will not be evaluated as // | an omission. Instead, it will be evaluated as undefined, which will be evaluated as zero. // | @param items Elements to insert into the array in place of the deleted elements. // | @returns An array containing the elements that were deleted. @@ -117,7 +117,7 @@ "name": "deleteCount", "documentation": [ { - "text": "The number of elements to remove. Omitting this argument will remove all elements from the start \nparamater location to end of the array. If value of this argument is either a negative number, zero, undefined, or a type \nthat cannot be coverted to an integer, the function will evaluate the argument as zero and not remove any elements.", + "text": "The number of elements to remove. Omitting this argument will remove all elements from the start\nparamater location to end of the array. If value of this argument is either a negative number, zero, undefined, or a type\nthat cannot be coverted to an integer, the function will evaluate the argument as zero and not remove any elements.", "kind": "text" } ], @@ -183,7 +183,7 @@ "kind": "space" }, { - "text": "The number of elements to remove. Omitting this argument will remove all elements from the start \nparamater location to end of the array. If value of this argument is either a negative number, zero, undefined, or a type \nthat cannot be coverted to an integer, the function will evaluate the argument as zero and not remove any elements.", + "text": "The number of elements to remove. Omitting this argument will remove all elements from the start\nparamater location to end of the array. If value of this argument is either a negative number, zero, undefined, or a type\nthat cannot be coverted to an integer, the function will evaluate the argument as zero and not remove any elements.", "kind": "text" } ] @@ -281,7 +281,7 @@ "name": "deleteCount", "documentation": [ { - "text": "The number of elements to remove. If value of this argument is either a negative number, zero,\nundefined, or a type that cannot be coverted to an integer, the function will evaluate the argument as zero and \nnot remove any elements. \nNote: If the deleteCount argument is left empty between the start and items arguments, it will not be evaluated as \nan omission. Instead, it will be evaluated as undefined, which will be evaluated as zero.", + "text": "The number of elements to remove. If value of this argument is either a negative number, zero,\nundefined, or a type that cannot be coverted to an integer, the function will evaluate the argument as zero and\nnot remove any elements.\nNote: If the deleteCount argument is left empty between the start and items arguments, it will not be evaluated as\nan omission. Instead, it will be evaluated as undefined, which will be evaluated as zero.", "kind": "text" } ], @@ -384,7 +384,7 @@ "kind": "space" }, { - "text": "The number of elements to remove. If value of this argument is either a negative number, zero,\nundefined, or a type that cannot be coverted to an integer, the function will evaluate the argument as zero and \nnot remove any elements. \nNote: If the deleteCount argument is left empty between the start and items arguments, it will not be evaluated as \nan omission. Instead, it will be evaluated as undefined, which will be evaluated as zero.", + "text": "The number of elements to remove. If value of this argument is either a negative number, zero,\nundefined, or a type that cannot be coverted to an integer, the function will evaluate the argument as zero and\nnot remove any elements.\nNote: If the deleteCount argument is left empty between the start and items arguments, it will not be evaluated as\nan omission. Instead, it will be evaluated as undefined, which will be evaluated as zero.", "kind": "text" } ] @@ -517,7 +517,7 @@ "name": "deleteCount", "documentation": [ { - "text": "The number of elements to remove. Omitting this argument will remove all elements from the start \nparamater location to end of the array. If value of this argument is either a negative number, zero, undefined, or a type \nthat cannot be coverted to an integer, the function will evaluate the argument as zero and not remove any elements.", + "text": "The number of elements to remove. Omitting this argument will remove all elements from the start\nparamater location to end of the array. If value of this argument is either a negative number, zero, undefined, or a type\nthat cannot be coverted to an integer, the function will evaluate the argument as zero and not remove any elements.", "kind": "text" } ], @@ -583,7 +583,7 @@ "kind": "space" }, { - "text": "The number of elements to remove. Omitting this argument will remove all elements from the start \nparamater location to end of the array. If value of this argument is either a negative number, zero, undefined, or a type \nthat cannot be coverted to an integer, the function will evaluate the argument as zero and not remove any elements.", + "text": "The number of elements to remove. Omitting this argument will remove all elements from the start\nparamater location to end of the array. If value of this argument is either a negative number, zero, undefined, or a type\nthat cannot be coverted to an integer, the function will evaluate the argument as zero and not remove any elements.", "kind": "text" } ] @@ -681,7 +681,7 @@ "name": "deleteCount", "documentation": [ { - "text": "The number of elements to remove. If value of this argument is either a negative number, zero,\nundefined, or a type that cannot be coverted to an integer, the function will evaluate the argument as zero and \nnot remove any elements. \nNote: If the deleteCount argument is left empty between the start and items arguments, it will not be evaluated as \nan omission. Instead, it will be evaluated as undefined, which will be evaluated as zero.", + "text": "The number of elements to remove. If value of this argument is either a negative number, zero,\nundefined, or a type that cannot be coverted to an integer, the function will evaluate the argument as zero and\nnot remove any elements.\nNote: If the deleteCount argument is left empty between the start and items arguments, it will not be evaluated as\nan omission. Instead, it will be evaluated as undefined, which will be evaluated as zero.", "kind": "text" } ], @@ -784,7 +784,7 @@ "kind": "space" }, { - "text": "The number of elements to remove. If value of this argument is either a negative number, zero,\nundefined, or a type that cannot be coverted to an integer, the function will evaluate the argument as zero and \nnot remove any elements. \nNote: If the deleteCount argument is left empty between the start and items arguments, it will not be evaluated as \nan omission. Instead, it will be evaluated as undefined, which will be evaluated as zero.", + "text": "The number of elements to remove. If value of this argument is either a negative number, zero,\nundefined, or a type that cannot be coverted to an integer, the function will evaluate the argument as zero and\nnot remove any elements.\nNote: If the deleteCount argument is left empty between the start and items arguments, it will not be evaluated as\nan omission. Instead, it will be evaluated as undefined, which will be evaluated as zero.", "kind": "text" } ] diff --git a/tests/baselines/reference/completionEntryForUnionMethod.baseline b/tests/baselines/reference/completionEntryForUnionMethod.baseline index 0c0fddaf1071f..52ffd38fd2c49 100644 --- a/tests/baselines/reference/completionEntryForUnionMethod.baseline +++ b/tests/baselines/reference/completionEntryForUnionMethod.baseline @@ -4404,7 +4404,7 @@ "kind": "space" }, { - "text": "The number of elements to remove. Omitting this argument will remove all elements from the start \nparamater location to end of the array. If value of this argument is either a negative number, zero, undefined, or a type \nthat cannot be coverted to an integer, the function will evaluate the argument as zero and not remove any elements.", + "text": "The number of elements to remove. Omitting this argument will remove all elements from the start\nparamater location to end of the array. If value of this argument is either a negative number, zero, undefined, or a type\nthat cannot be coverted to an integer, the function will evaluate the argument as zero and not remove any elements.", "kind": "text" } ] diff --git a/tests/baselines/reference/goToTypeDefinition_arrayType.baseline.jsonc b/tests/baselines/reference/goToTypeDefinition_arrayType.baseline.jsonc index ad7182f4ca179..01040788fd913 100644 --- a/tests/baselines/reference/goToTypeDefinition_arrayType.baseline.jsonc +++ b/tests/baselines/reference/goToTypeDefinition_arrayType.baseline.jsonc @@ -87,9 +87,9 @@ // /** // * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. // * @param start The zero-based location in the array from which to start removing elements. -// * @param deleteCount The number of elements to remove. Omitting this argument will remove all elements from the start -// * paramater location to end of the array. If value of this argument is either a negative number, zero, undefined, or a type -// * that cannot be coverted to an integer, the function will evaluate the argument as zero and not remove any elements. +// * @param deleteCount The number of elements to remove. Omitting this argument will remove all elements from the start +// * paramater location to end of the array. If value of this argument is either a negative number, zero, undefined, or a type +// * that cannot be coverted to an integer, the function will evaluate the argument as zero and not remove any elements. // * @returns An array containing the elements that were deleted. // */ // splice(start: number, deleteCount?: number): T[]; @@ -97,10 +97,10 @@ // * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. // * @param start The zero-based location in the array from which to start removing elements. // * @param deleteCount The number of elements to remove. If value of this argument is either a negative number, zero, -// * undefined, or a type that cannot be coverted to an integer, the function will evaluate the argument as zero and -// * not remove any elements. -// * Note: If the deleteCount argument is left empty between the start and items arguments, it will not be evaluated as -// * an omission. Instead, it will be evaluated as undefined, which will be evaluated as zero. +// * undefined, or a type that cannot be coverted to an integer, the function will evaluate the argument as zero and +// * not remove any elements. +// * Note: If the deleteCount argument is left empty between the start and items arguments, it will not be evaluated as +// * an omission. Instead, it will be evaluated as undefined, which will be evaluated as zero. // * @param items Elements to insert into the array in place of the deleted elements. // * @returns An array containing the elements that were deleted. // */ @@ -346,9 +346,9 @@ // /** // * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. // * @param start The zero-based location in the array from which to start removing elements. -// * @param deleteCount The number of elements to remove. Omitting this argument will remove all elements from the start -// * paramater location to end of the array. If value of this argument is either a negative number, zero, undefined, or a type -// * that cannot be coverted to an integer, the function will evaluate the argument as zero and not remove any elements. +// * @param deleteCount The number of elements to remove. Omitting this argument will remove all elements from the start +// * paramater location to end of the array. If value of this argument is either a negative number, zero, undefined, or a type +// * that cannot be coverted to an integer, the function will evaluate the argument as zero and not remove any elements. // * @returns An array containing the elements that were deleted. // */ // splice(start: number, deleteCount?: number): T[]; @@ -356,10 +356,10 @@ // * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. // * @param start The zero-based location in the array from which to start removing elements. // * @param deleteCount The number of elements to remove. If value of this argument is either a negative number, zero, -// * undefined, or a type that cannot be coverted to an integer, the function will evaluate the argument as zero and -// * not remove any elements. -// * Note: If the deleteCount argument is left empty between the start and items arguments, it will not be evaluated as -// * an omission. Instead, it will be evaluated as undefined, which will be evaluated as zero. +// * undefined, or a type that cannot be coverted to an integer, the function will evaluate the argument as zero and +// * not remove any elements. +// * Note: If the deleteCount argument is left empty between the start and items arguments, it will not be evaluated as +// * an omission. Instead, it will be evaluated as undefined, which will be evaluated as zero. // * @param items Elements to insert into the array in place of the deleted elements. // * @returns An array containing the elements that were deleted. // */