Skip to content

Commit 30d1ecd

Browse files
committed
Constraint for { [P in K]: XXX } should be empty type
1 parent e46c846 commit 30d1ecd

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6832,11 +6832,9 @@ namespace ts {
68326832
}
68336833
}
68346834
else {
6835-
// First, if the constraint type is a type parameter, obtain the base constraint. Then,
6836-
// if the key type is a 'keyof X', obtain 'keyof C' where C is the base constraint of X.
6837-
// Finally, iterate over the constituents of the resulting iteration type.
6838-
const keyType = constraintType.flags & TypeFlags.InstantiableNonPrimitive ? getApparentType(constraintType) : constraintType;
6839-
const iterationType = keyType.flags & TypeFlags.Index ? getIndexType(getApparentType((<IndexType>keyType).type)) : keyType;
6835+
// If the key type is a 'keyof X', obtain 'keyof C' where C is the base constraint of X.
6836+
// Then iterate over the constituents of the key type.
6837+
const iterationType = constraintType.flags & TypeFlags.Index ? getIndexType(getApparentType((<IndexType>constraintType).type)) : constraintType;
68406838
forEachType(iterationType, addMemberForKeyType);
68416839
}
68426840
setStructuredTypeMembers(type, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo);

0 commit comments

Comments
 (0)