File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -21770,9 +21770,14 @@ namespace ts {
21770
21770
return getTypeOfParameter(signature.parameters[pos]);
21771
21771
}
21772
21772
if (signature.hasRestParameter) {
21773
+ // We want to return the value undefined for an out of bounds parameter position,
21774
+ // so we need to check bounds here before calling getIndexedAccessType (which
21775
+ // otherwise would return the type 'undefined').
21773
21776
const restType = getTypeOfSymbol(signature.parameters[paramCount]);
21774
- const indexType = getLiteralType(pos - paramCount);
21775
- return getIndexedAccessType(restType, indexType);
21777
+ const index = pos - paramCount;
21778
+ if (!isTupleType(restType) || restType.target.hasRestElement || index < (restType.typeArguments || emptyArray).length) {
21779
+ return getIndexedAccessType(restType, getLiteralType(index));
21780
+ }
21776
21781
}
21777
21782
return undefined;
21778
21783
}
You can’t perform that action at this time.
0 commit comments