Fixed tuple types indexed by a type parameter (#51037)

* Fixed tuple types indexed by a type parameter

* If only there was a tool to add that missing semicolon for me

* Rename to baseConstraint

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
This commit is contained in:
Josh Goldberg
2022-12-09 10:59:40 -05:00
committed by GitHub
parent 212d3864ef
commit f3d55db45a
6 changed files with 72 additions and 4 deletions

View File

@@ -10090,8 +10090,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
// If the parent is a tuple type, the rest element has a tuple type of the
// remaining tuple element types. Otherwise, the rest element has an array type with same
// element type as the parent type.
type = everyType(parentType, isTupleType) ?
mapType(parentType, t => sliceTupleType(t as TupleTypeReference, index)) :
const baseConstraint = getBaseConstraintOrType(parentType);
type = everyType(baseConstraint, isTupleType) ?
mapType(baseConstraint, t => sliceTupleType(t as TupleTypeReference, index)) :
createArrayType(elementType);
}
else if (isArrayLikeType(parentType)) {