getPropertiesOfUnionOrIntersectionType: handle types with index signature (#31979)

* getPropertiesOfUnionOrIntersectionType: handle types with index signature

Fixes: #31565

* fix test

* more testing

* fix typo in checker.ts

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
This commit is contained in:
Klaus Meinhardt
2020-03-13 22:30:53 +01:00
committed by GitHub
parent 4432178ded
commit 8b6bd41ce7
3 changed files with 20 additions and 11 deletions

View File

@@ -9842,8 +9842,8 @@ namespace ts {
}
}
// The properties of a union type are those that are present in all constituent types, so
// we only need to check the properties of the first type
if (type.flags & TypeFlags.Union) {
// we only need to check the properties of the first type without index signature
if (type.flags & TypeFlags.Union && !getIndexInfoOfType(current, IndexKind.String) && !getIndexInfoOfType(current, IndexKind.Number)) {
break;
}
}