@@ -21550,32 +21550,31 @@ namespace ts {
21550
21550
}
21551
21551
if (signature.hasRestParameter) {
21552
21552
const restType = getTypeOfSymbol(signature.parameters[paramCount]);
21553
- if (isTupleType(restType)) {
21554
- if (pos - paramCount < getLengthOfTupleType(restType)) {
21555
- return restType.typeArguments![pos - paramCount];
21556
- }
21557
- return getRestTypeOfTupleType(restType);
21558
- }
21559
- return getIndexTypeOfType(restType, IndexKind.Number);
21553
+ const indexType = getLiteralType(pos - paramCount);
21554
+ return getIndexedAccessType(restType, indexType);
21560
21555
}
21561
21556
return undefined;
21562
21557
}
21563
21558
21564
21559
function getRestTypeAtPosition(source: Signature, pos: number): Type {
21565
21560
const paramCount = getParameterCount(source);
21566
21561
const restType = getEffectiveRestType(source);
21567
- if (restType && pos === paramCount - 1) {
21562
+ const nonRestCount = paramCount - (restType ? 1 : 0);
21563
+ if (restType && pos === nonRestCount) {
21568
21564
return restType;
21569
21565
}
21570
- const start = restType ? Math.min(pos, paramCount - 1) : pos;
21571
21566
const types = [];
21572
21567
const names = [];
21573
- for (let i = start ; i < paramCount ; i++) {
21568
+ for (let i = pos ; i < nonRestCount ; i++) {
21574
21569
types.push(getTypeAtPosition(source, i));
21575
21570
names.push(getParameterNameAtPosition(source, i));
21576
21571
}
21572
+ if (restType) {
21573
+ types.push(getIndexedAccessType(restType, numberType));
21574
+ names.push(getParameterNameAtPosition(source, nonRestCount));
21575
+ }
21577
21576
const minArgumentCount = getMinArgumentCount(source);
21578
- const minLength = minArgumentCount < start ? 0 : minArgumentCount - start ;
21577
+ const minLength = minArgumentCount < pos ? 0 : minArgumentCount - pos ;
21579
21578
return createTupleType(types, minLength, !!restType, /*readonly*/ false, names);
21580
21579
}
21581
21580
0 commit comments