Skip to content

Commit

Permalink
Simplify keyof NoInfer<T> ==> NoInfer<keyof T> transformation
Browse files Browse the repository at this point in the history
  • Loading branch information
ahejlsberg committed Dec 20, 2023
1 parent 63b6713 commit 14b90c2
Showing 1 changed file with 3 additions and 3 deletions.
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

0 comments on commit 14b90c2

Please sign in to comment.