diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts
index 28f0d188854bb..d230fee133484 100644
--- a/src/services/signatureHelp.ts
+++ b/src/services/signatureHelp.ts
@@ -287,9 +287,6 @@ function getArgumentOrParameterListInfo(node: Node, position: number, sourceFile
const { list, argumentIndex } = info;
const argumentCount = getArgumentCount(checker, list);
- if (argumentIndex !== 0) {
- Debug.assertLessThan(argumentIndex, argumentCount);
- }
const argumentsSpan = getApplicableSpanForArguments(list, sourceFile);
return { list, argumentIndex, argumentCount, argumentsSpan };
}
@@ -660,9 +657,6 @@ function createSignatureHelpItems(
const callTargetDisplayParts = callTargetSymbol ? symbolToDisplayParts(typeChecker, callTargetSymbol, useFullPrefix ? sourceFile : undefined, /*meaning*/ undefined) : emptyArray;
const items = map(candidates, candidateSignature => getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, typeChecker, enclosingDeclaration, sourceFile));
- if (argumentIndex !== 0) {
- Debug.assertLessThan(argumentIndex, argumentCount);
- }
let selectedItemIndex = 0;
let itemsSeen = 0;
for (let i = 0; i < items.length; i++) {
diff --git a/tests/baselines/reference/signatureHelpRestArgs3.baseline b/tests/baselines/reference/signatureHelpRestArgs3.baseline
new file mode 100644
index 0000000000000..b4c8dfd56b586
--- /dev/null
+++ b/tests/baselines/reference/signatureHelpRestArgs3.baseline
@@ -0,0 +1,1018 @@
+// === SignatureHelp ===
+=== /tests/cases/fourslash/signatureHelpRestArgs3.ts ===
+// const layers = Object.assign({}, ...[]);
+// ^
+// | ----------------------------------------------------------------------
+// | assign(target: object, **...sources: any[]**): any
+// | Copy the values of all of the enumerable own properties from one or more source objects to a
+// | target object. Returns the target object.
+// | @param target The target object to copy to.
+// | @param sources One or more source objects from which to copy properties
+// | ----------------------------------------------------------------------
+
+[
+ {
+ "marker": {
+ "fileName": "/tests/cases/fourslash/signatureHelpRestArgs3.ts",
+ "position": 33,
+ "name": "1"
+ },
+ "item": {
+ "items": [
+ {
+ "isVariadic": false,
+ "prefixDisplayParts": [
+ {
+ "text": "assign",
+ "kind": "methodName"
+ },
+ {
+ "text": "<",
+ "kind": "punctuation"
+ },
+ {
+ "text": "T",
+ "kind": "typeParameterName"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "extends",
+ "kind": "keyword"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "{",
+ "kind": "punctuation"
+ },
+ {
+ "text": "}",
+ "kind": "punctuation"
+ },
+ {
+ "text": ",",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "U",
+ "kind": "typeParameterName"
+ },
+ {
+ "text": ">",
+ "kind": "punctuation"
+ },
+ {
+ "text": "(",
+ "kind": "punctuation"
+ }
+ ],
+ "suffixDisplayParts": [
+ {
+ "text": ")",
+ "kind": "punctuation"
+ },
+ {
+ "text": ":",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "T",
+ "kind": "typeParameterName"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "&",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "U",
+ "kind": "typeParameterName"
+ }
+ ],
+ "separatorDisplayParts": [
+ {
+ "text": ",",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ }
+ ],
+ "parameters": [
+ {
+ "name": "target",
+ "documentation": [
+ {
+ "text": "The target object to copy to.",
+ "kind": "text"
+ }
+ ],
+ "displayParts": [
+ {
+ "text": "target",
+ "kind": "parameterName"
+ },
+ {
+ "text": ":",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "T",
+ "kind": "typeParameterName"
+ }
+ ],
+ "isOptional": false,
+ "isRest": false
+ },
+ {
+ "name": "source",
+ "documentation": [
+ {
+ "text": "The source object from which to copy properties.",
+ "kind": "text"
+ }
+ ],
+ "displayParts": [
+ {
+ "text": "source",
+ "kind": "parameterName"
+ },
+ {
+ "text": ":",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "U",
+ "kind": "typeParameterName"
+ }
+ ],
+ "isOptional": false,
+ "isRest": false
+ }
+ ],
+ "documentation": [
+ {
+ "text": "Copy the values of all of the enumerable own properties from one or more source objects to a\ntarget object. Returns the target object.",
+ "kind": "text"
+ }
+ ],
+ "tags": [
+ {
+ "name": "param",
+ "text": [
+ {
+ "text": "target",
+ "kind": "parameterName"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "The target object to copy to.",
+ "kind": "text"
+ }
+ ]
+ },
+ {
+ "name": "param",
+ "text": [
+ {
+ "text": "source",
+ "kind": "parameterName"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "The source object from which to copy properties.",
+ "kind": "text"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "isVariadic": false,
+ "prefixDisplayParts": [
+ {
+ "text": "assign",
+ "kind": "methodName"
+ },
+ {
+ "text": "<",
+ "kind": "punctuation"
+ },
+ {
+ "text": "T",
+ "kind": "typeParameterName"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "extends",
+ "kind": "keyword"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "{",
+ "kind": "punctuation"
+ },
+ {
+ "text": "}",
+ "kind": "punctuation"
+ },
+ {
+ "text": ",",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "U",
+ "kind": "typeParameterName"
+ },
+ {
+ "text": ",",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "V",
+ "kind": "typeParameterName"
+ },
+ {
+ "text": ">",
+ "kind": "punctuation"
+ },
+ {
+ "text": "(",
+ "kind": "punctuation"
+ }
+ ],
+ "suffixDisplayParts": [
+ {
+ "text": ")",
+ "kind": "punctuation"
+ },
+ {
+ "text": ":",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "T",
+ "kind": "typeParameterName"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "&",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "U",
+ "kind": "typeParameterName"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "&",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "V",
+ "kind": "typeParameterName"
+ }
+ ],
+ "separatorDisplayParts": [
+ {
+ "text": ",",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ }
+ ],
+ "parameters": [
+ {
+ "name": "target",
+ "documentation": [
+ {
+ "text": "The target object to copy to.",
+ "kind": "text"
+ }
+ ],
+ "displayParts": [
+ {
+ "text": "target",
+ "kind": "parameterName"
+ },
+ {
+ "text": ":",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "T",
+ "kind": "typeParameterName"
+ }
+ ],
+ "isOptional": false,
+ "isRest": false
+ },
+ {
+ "name": "source1",
+ "documentation": [
+ {
+ "text": "The first source object from which to copy properties.",
+ "kind": "text"
+ }
+ ],
+ "displayParts": [
+ {
+ "text": "source1",
+ "kind": "parameterName"
+ },
+ {
+ "text": ":",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "U",
+ "kind": "typeParameterName"
+ }
+ ],
+ "isOptional": false,
+ "isRest": false
+ },
+ {
+ "name": "source2",
+ "documentation": [
+ {
+ "text": "The second source object from which to copy properties.",
+ "kind": "text"
+ }
+ ],
+ "displayParts": [
+ {
+ "text": "source2",
+ "kind": "parameterName"
+ },
+ {
+ "text": ":",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "V",
+ "kind": "typeParameterName"
+ }
+ ],
+ "isOptional": false,
+ "isRest": false
+ }
+ ],
+ "documentation": [
+ {
+ "text": "Copy the values of all of the enumerable own properties from one or more source objects to a\ntarget object. Returns the target object.",
+ "kind": "text"
+ }
+ ],
+ "tags": [
+ {
+ "name": "param",
+ "text": [
+ {
+ "text": "target",
+ "kind": "parameterName"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "The target object to copy to.",
+ "kind": "text"
+ }
+ ]
+ },
+ {
+ "name": "param",
+ "text": [
+ {
+ "text": "source1",
+ "kind": "parameterName"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "The first source object from which to copy properties.",
+ "kind": "text"
+ }
+ ]
+ },
+ {
+ "name": "param",
+ "text": [
+ {
+ "text": "source2",
+ "kind": "parameterName"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "The second source object from which to copy properties.",
+ "kind": "text"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "isVariadic": false,
+ "prefixDisplayParts": [
+ {
+ "text": "assign",
+ "kind": "methodName"
+ },
+ {
+ "text": "<",
+ "kind": "punctuation"
+ },
+ {
+ "text": "T",
+ "kind": "typeParameterName"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "extends",
+ "kind": "keyword"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "{",
+ "kind": "punctuation"
+ },
+ {
+ "text": "}",
+ "kind": "punctuation"
+ },
+ {
+ "text": ",",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "U",
+ "kind": "typeParameterName"
+ },
+ {
+ "text": ",",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "V",
+ "kind": "typeParameterName"
+ },
+ {
+ "text": ",",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "W",
+ "kind": "typeParameterName"
+ },
+ {
+ "text": ">",
+ "kind": "punctuation"
+ },
+ {
+ "text": "(",
+ "kind": "punctuation"
+ }
+ ],
+ "suffixDisplayParts": [
+ {
+ "text": ")",
+ "kind": "punctuation"
+ },
+ {
+ "text": ":",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "T",
+ "kind": "typeParameterName"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "&",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "U",
+ "kind": "typeParameterName"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "&",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "V",
+ "kind": "typeParameterName"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "&",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "W",
+ "kind": "typeParameterName"
+ }
+ ],
+ "separatorDisplayParts": [
+ {
+ "text": ",",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ }
+ ],
+ "parameters": [
+ {
+ "name": "target",
+ "documentation": [
+ {
+ "text": "The target object to copy to.",
+ "kind": "text"
+ }
+ ],
+ "displayParts": [
+ {
+ "text": "target",
+ "kind": "parameterName"
+ },
+ {
+ "text": ":",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "T",
+ "kind": "typeParameterName"
+ }
+ ],
+ "isOptional": false,
+ "isRest": false
+ },
+ {
+ "name": "source1",
+ "documentation": [
+ {
+ "text": "The first source object from which to copy properties.",
+ "kind": "text"
+ }
+ ],
+ "displayParts": [
+ {
+ "text": "source1",
+ "kind": "parameterName"
+ },
+ {
+ "text": ":",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "U",
+ "kind": "typeParameterName"
+ }
+ ],
+ "isOptional": false,
+ "isRest": false
+ },
+ {
+ "name": "source2",
+ "documentation": [
+ {
+ "text": "The second source object from which to copy properties.",
+ "kind": "text"
+ }
+ ],
+ "displayParts": [
+ {
+ "text": "source2",
+ "kind": "parameterName"
+ },
+ {
+ "text": ":",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "V",
+ "kind": "typeParameterName"
+ }
+ ],
+ "isOptional": false,
+ "isRest": false
+ },
+ {
+ "name": "source3",
+ "documentation": [
+ {
+ "text": "The third source object from which to copy properties.",
+ "kind": "text"
+ }
+ ],
+ "displayParts": [
+ {
+ "text": "source3",
+ "kind": "parameterName"
+ },
+ {
+ "text": ":",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "W",
+ "kind": "typeParameterName"
+ }
+ ],
+ "isOptional": false,
+ "isRest": false
+ }
+ ],
+ "documentation": [
+ {
+ "text": "Copy the values of all of the enumerable own properties from one or more source objects to a\ntarget object. Returns the target object.",
+ "kind": "text"
+ }
+ ],
+ "tags": [
+ {
+ "name": "param",
+ "text": [
+ {
+ "text": "target",
+ "kind": "parameterName"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "The target object to copy to.",
+ "kind": "text"
+ }
+ ]
+ },
+ {
+ "name": "param",
+ "text": [
+ {
+ "text": "source1",
+ "kind": "parameterName"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "The first source object from which to copy properties.",
+ "kind": "text"
+ }
+ ]
+ },
+ {
+ "name": "param",
+ "text": [
+ {
+ "text": "source2",
+ "kind": "parameterName"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "The second source object from which to copy properties.",
+ "kind": "text"
+ }
+ ]
+ },
+ {
+ "name": "param",
+ "text": [
+ {
+ "text": "source3",
+ "kind": "parameterName"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "The third source object from which to copy properties.",
+ "kind": "text"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "isVariadic": true,
+ "prefixDisplayParts": [
+ {
+ "text": "assign",
+ "kind": "methodName"
+ },
+ {
+ "text": "(",
+ "kind": "punctuation"
+ }
+ ],
+ "suffixDisplayParts": [
+ {
+ "text": ")",
+ "kind": "punctuation"
+ },
+ {
+ "text": ":",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "any",
+ "kind": "keyword"
+ }
+ ],
+ "separatorDisplayParts": [
+ {
+ "text": ",",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ }
+ ],
+ "parameters": [
+ {
+ "name": "target",
+ "documentation": [
+ {
+ "text": "The target object to copy to.",
+ "kind": "text"
+ }
+ ],
+ "displayParts": [
+ {
+ "text": "target",
+ "kind": "parameterName"
+ },
+ {
+ "text": ":",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "object",
+ "kind": "keyword"
+ }
+ ],
+ "isOptional": false,
+ "isRest": false
+ },
+ {
+ "name": "sources",
+ "documentation": [
+ {
+ "text": "One or more source objects from which to copy properties",
+ "kind": "text"
+ }
+ ],
+ "displayParts": [
+ {
+ "text": "...",
+ "kind": "punctuation"
+ },
+ {
+ "text": "sources",
+ "kind": "parameterName"
+ },
+ {
+ "text": ":",
+ "kind": "punctuation"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "any",
+ "kind": "keyword"
+ },
+ {
+ "text": "[",
+ "kind": "punctuation"
+ },
+ {
+ "text": "]",
+ "kind": "punctuation"
+ }
+ ],
+ "isOptional": false,
+ "isRest": false
+ }
+ ],
+ "documentation": [
+ {
+ "text": "Copy the values of all of the enumerable own properties from one or more source objects to a\ntarget object. Returns the target object.",
+ "kind": "text"
+ }
+ ],
+ "tags": [
+ {
+ "name": "param",
+ "text": [
+ {
+ "text": "target",
+ "kind": "parameterName"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "The target object to copy to.",
+ "kind": "text"
+ }
+ ]
+ },
+ {
+ "name": "param",
+ "text": [
+ {
+ "text": "sources",
+ "kind": "parameterName"
+ },
+ {
+ "text": " ",
+ "kind": "space"
+ },
+ {
+ "text": "One or more source objects from which to copy properties",
+ "kind": "text"
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "applicableSpan": {
+ "start": 29,
+ "length": 9
+ },
+ "selectedItemIndex": 3,
+ "argumentIndex": 1,
+ "argumentCount": 1
+ }
+ }
+]
\ No newline at end of file
diff --git a/tests/cases/fourslash/completionsBeforeRestArg1.ts b/tests/cases/fourslash/completionsBeforeRestArg1.ts
new file mode 100644
index 0000000000000..b267f2366bd2e
--- /dev/null
+++ b/tests/cases/fourslash/completionsBeforeRestArg1.ts
@@ -0,0 +1,12 @@
+///
+
+// @target: esnext
+// @lib: esnext
+
+//// const layers = Object.assign({}, /*1*/...[]);
+
+verify.completions({
+ marker: "1",
+ includes: completion.globals,
+ isNewIdentifierLocation: true,
+});
diff --git a/tests/cases/fourslash/signatureHelpRestArgs3.ts b/tests/cases/fourslash/signatureHelpRestArgs3.ts
new file mode 100644
index 0000000000000..cc2ee27c8842b
--- /dev/null
+++ b/tests/cases/fourslash/signatureHelpRestArgs3.ts
@@ -0,0 +1,8 @@
+///
+
+// @target: esnext
+// @lib: esnext
+
+//// const layers = Object.assign({}, /*1*/...[]);
+
+verify.baselineSignatureHelp();