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