Skip to content

Commit bc709a8

Browse files
author
Andy
authored
Fix bug where array element is undefined (#26433)
* Fix bug where array element is undefined * Better fix
1 parent a5326e6 commit bc709a8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3470,8 +3470,8 @@ namespace ts {
34703470
const arity = getTypeReferenceArity(type);
34713471
const tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context);
34723472
const hasRestElement = (<TupleType>type.target).hasRestElement;
3473-
if (tupleConstituentNodes && tupleConstituentNodes.length > 0) {
3474-
for (let i = (<TupleType>type.target).minLength; i < arity; i++) {
3473+
if (tupleConstituentNodes) {
3474+
for (let i = (<TupleType>type.target).minLength; i < Math.min(arity, tupleConstituentNodes.length); i++) {
34753475
tupleConstituentNodes[i] = hasRestElement && i === arity - 1 ?
34763476
createRestTypeNode(createArrayTypeNode(tupleConstituentNodes[i])) :
34773477
createOptionalTypeNode(tupleConstituentNodes[i]);

0 commit comments

Comments
 (0)