@@ -10340,9 +10340,6 @@ namespace ts {
10340
10340
// bound includes those keys that are known to always be present, for example because
10341
10341
// because of constraints on type parameters (e.g. 'keyof T' for a constrained T).
10342
10342
function getLowerBoundOfKeyType(type: Type): Type {
10343
- if (type.flags & (TypeFlags.Any | TypeFlags.Primitive)) {
10344
- return type;
10345
- }
10346
10343
if (type.flags & TypeFlags.Index) {
10347
10344
const t = getApparentType((<IndexType>type).type);
10348
10345
return isGenericTupleType(t) ? getKnownKeysOfTupleType(t) : getIndexType(t);
@@ -10363,7 +10360,7 @@ namespace ts {
10363
10360
if (type.flags & TypeFlags.Intersection) {
10364
10361
return getIntersectionType(sameMap((<UnionType>type).types, getLowerBoundOfKeyType));
10365
10362
}
10366
- return neverType ;
10363
+ return type ;
10367
10364
}
10368
10365
10369
10366
/** Resolve the members of a mapped type { [P in K]: T } */
@@ -31397,12 +31394,14 @@ namespace ts {
31397
31394
}
31398
31395
31399
31396
const type = <MappedType>getTypeFromMappedTypeNode(node);
31400
- const constraintType = getConstraintTypeFromMappedType(type);
31401
- checkTypeAssignableTo(constraintType, keyofConstraintType, getEffectiveConstraintOfTypeParameter(node.typeParameter));
31402
31397
const nameType = getNameTypeFromMappedType(type);
31403
31398
if (nameType) {
31404
31399
checkTypeAssignableTo(nameType, keyofConstraintType, node.nameType);
31405
31400
}
31401
+ else {
31402
+ const constraintType = getConstraintTypeFromMappedType(type);
31403
+ checkTypeAssignableTo(constraintType, keyofConstraintType, getEffectiveConstraintOfTypeParameter(node.typeParameter));
31404
+ }
31406
31405
}
31407
31406
31408
31407
function checkThisType(node: ThisTypeNode) {
0 commit comments