Merge pull request #23966 from Microsoft/fixIndexedAccessAnyConstraint

Fix indexed access with 'any' constraint
This commit is contained in:
Anders Hejlsberg
2018-05-08 12:21:00 -07:00
committed by GitHub
5 changed files with 68 additions and 1 deletions

View File

@@ -10755,7 +10755,7 @@ namespace ts {
}
}
const constraint = getConstraintForRelation(<TypeParameter>source);
if (!constraint || constraint.flags & TypeFlags.Any) {
if (!constraint || (source.flags & TypeFlags.TypeParameter && constraint.flags & TypeFlags.Any)) {
// A type variable with no constraint is not related to the non-primitive object type.
if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~TypeFlags.NonPrimitive))) {
errorInfo = saveErrorInfo;