Skip to content

Commit 44a6c6c

Browse files
committed
{ [P in K]: T } is related to { [x: string]: U } if T is related to U
1 parent 86d0fa2 commit 44a6c6c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/compiler/checker.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9614,6 +9614,11 @@ namespace ts {
96149614
if (sourceInfo) {
96159615
return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors);
96169616
}
9617+
if (isGenericMappedType(source)) {
9618+
// A generic mapped type { [P in K]: T } is related to an index signature { [x: string]: U }
9619+
// if T is related to U.
9620+
return kind === IndexKind.String && isRelatedTo(getTemplateTypeFromMappedType(<MappedType>source), targetInfo.type, reportErrors);
9621+
}
96179622
if (isObjectLiteralType(source)) {
96189623
let related = Ternary.True;
96199624
if (kind === IndexKind.String) {

0 commit comments

Comments
 (0)