Propagate constness of type parameters in variadic tuples (#52129)

This commit is contained in:
Anders Hejlsberg
2023-01-13 07:23:04 -08:00
committed by GitHub
parent ef58695fbc
commit 36e9570933
6 changed files with 88 additions and 0 deletions
+1
View File
@@ -13256,6 +13256,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
function isConstTypeVariable(type: Type): boolean {
return !!(type.flags & TypeFlags.TypeParameter && some((type as TypeParameter).symbol?.declarations, d => hasSyntacticModifier(d, ModifierFlags.Const)) ||
isGenericTupleType(type) && findIndex(getTypeArguments(type), (t, i) => !!(type.target.elementFlags[i] & ElementFlags.Variadic) && isConstTypeVariable(t)) >= 0 ||
type.flags & TypeFlags.IndexedAccess && isConstTypeVariable((type as IndexedAccessType).objectType));
}