mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 11:24:49 -05:00
Extend isTupleLikeType to also check if .length is a number literal type (#52617)
This commit is contained in:
committed by
GitHub
parent
34f6e107a3
commit
3073b5209b
@@ -23303,7 +23303,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
}
|
||||
|
||||
function isTupleLikeType(type: Type): boolean {
|
||||
return isTupleType(type) || !!getPropertyOfType(type, "0" as __String);
|
||||
let lengthType;
|
||||
return isTupleType(type) ||
|
||||
!!getPropertyOfType(type, "0" as __String) ||
|
||||
isArrayLikeType(type) && !!(lengthType = getTypeOfPropertyOfType(type, "length" as __String)) && everyType(lengthType, t => !!(t.flags & TypeFlags.NumberLiteral));
|
||||
}
|
||||
|
||||
function isArrayOrTupleLikeType(type: Type): boolean {
|
||||
|
||||
Reference in New Issue
Block a user