Merge pull request #17633 from Microsoft/indexSignatureMappedType

Mapped type and string index signature relations
This commit is contained in:
Anders Hejlsberg
2017-08-07 14:17:29 -07:00
committed by GitHub
4 changed files with 160 additions and 0 deletions
+5
View File
@@ -9671,6 +9671,11 @@ namespace ts {
if (sourceInfo) {
return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors);
}
if (isGenericMappedType(source)) {
// A generic mapped type { [P in K]: T } is related to an index signature { [x: string]: U }
// if T is related to U.
return kind === IndexKind.String && isRelatedTo(getTemplateTypeFromMappedType(<MappedType>source), targetInfo.type, reportErrors);
}
if (isObjectLiteralType(source)) {
let related = Ternary.True;
if (kind === IndexKind.String) {