Skip to content
Prev Previous commit
Next Next commit
Simplify keyof NoInfer<T> ==> NoInfer<keyof T> transformation
  • Loading branch information
ahejlsberg committed Dec 20, 2023
commit 14b90c23ca311981a1b7495437162999a730c634
6 changes: 3 additions & 3 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17760,7 +17760,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}

function shouldDeferIndexType(type: Type, indexFlags = IndexFlags.None) {
return !!(type.flags & TypeFlags.InstantiableNonPrimitive && !isNoInferType(type) ||
return !!(type.flags & TypeFlags.InstantiableNonPrimitive ||
isGenericTupleType(type) ||
isGenericMappedType(type) && (!hasDistributiveNameType(type) || getMappedTypeNameTypeKind(type) === MappedTypeNameTypeKind.Remapping) ||
type.flags & TypeFlags.Union && !(indexFlags & IndexFlags.NoReducibleCheck) && isGenericReducibleType(type) ||
Expand All @@ -17769,10 +17769,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {

function getIndexType(type: Type, indexFlags = defaultIndexFlags): Type {
type = getReducedType(type);
return shouldDeferIndexType(type, indexFlags) ? getIndexTypeForGenericType(type as InstantiableType | UnionOrIntersectionType, indexFlags) :
return isNoInferType(type) ? getNoInferType(getIndexType((type as SubstitutionType).baseType, indexFlags)) :
shouldDeferIndexType(type, indexFlags) ? getIndexTypeForGenericType(type as InstantiableType | UnionOrIntersectionType, indexFlags) :
type.flags & TypeFlags.Union ? getIntersectionType(map((type as UnionType).types, t => getIndexType(t, indexFlags))) :
type.flags & TypeFlags.Intersection ? getUnionType(map((type as IntersectionType).types, t => getIndexType(t, indexFlags))) :
type.flags & TypeFlags.Substitution ? getNoInferType(getIndexType((type as SubstitutionType).baseType, indexFlags)) :
getObjectFlags(type) & ObjectFlags.Mapped ? getIndexTypeForMappedType(type as MappedType, indexFlags) :
type === wildcardType ? wildcardType :
type.flags & TypeFlags.Unknown ? neverType :
Expand Down