Merge pull request #21866 from Microsoft/fixIndexedAccessWildcard

Fix indexed access issue with conditional types
This commit is contained in:
Anders Hejlsberg
2018-02-12 14:18:44 -08:00
committed by GitHub
6 changed files with 166 additions and 1 deletions
+1 -1
View File
@@ -7991,7 +7991,7 @@ namespace ts {
}
if (!(indexType.flags & TypeFlags.Nullable) && isTypeAssignableToKind(indexType, TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.ESSymbolLike)) {
if (isTypeAny(objectType)) {
return anyType;
return objectType;
}
const indexInfo = isTypeAssignableToKind(indexType, TypeFlags.NumberLike) && getIndexInfoOfType(objectType, IndexKind.Number) ||
getIndexInfoOfType(objectType, IndexKind.String) ||