Skip to content

Commit aca1ab3

Browse files
committed
Check mapped type constraint is assignable to string | number
1 parent de2da2c commit aca1ab3

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/compiler/checker.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15316,11 +15316,12 @@ namespace ts {
1531615316
}
1531715317

1531815318
function checkMappedType(node: MappedTypeNode) {
15319-
getTypeFromMappedTypeNode(node);
15320-
// const type = <MappedType>getTypeFromMappedTypeNode(node);
15321-
// const constraintType = getConstraintTypeFromMappedType(type);
15322-
// const keyType = constraintType.flags & TypeFlags.TypeParameter ? getApparentTypeOfTypeParameter(<TypeParameter>constraintType) : constraintType;
15323-
// checkTypeAssignableTo(keyType, stringOrNumberType, node.typeParameter.constraint);
15319+
checkSourceElement(node.typeParameter);
15320+
checkSourceElement(node.type);
15321+
const type = <MappedType>getTypeFromMappedTypeNode(node);
15322+
const constraintType = getConstraintTypeFromMappedType(type);
15323+
const keyType = constraintType.flags & TypeFlags.TypeParameter ? getApparentTypeOfTypeParameter(<TypeParameter>constraintType) : constraintType;
15324+
checkTypeAssignableTo(keyType, stringOrNumberType, node.typeParameter.constraint);
1532415325
}
1532515326

1532615327
function isPrivateWithinAmbient(node: Node): boolean {

0 commit comments

Comments
 (0)