* Fix #38608

* Work for narrowed non-unions

* Add comment
This commit is contained in:
Jack Williams
2021-03-11 15:32:49 +00:00
committed by GitHub
parent 79d3058b83
commit 3d6650eb4f
9 changed files with 369 additions and 11 deletions

View File

@@ -22963,7 +22963,8 @@ namespace ts {
}
function narrowByInKeyword(type: Type, literal: LiteralExpression, assumeTrue: boolean) {
if (type.flags & (TypeFlags.Union | TypeFlags.Object)
if (type.flags & TypeFlags.Union
|| type.flags & TypeFlags.Object && declaredType !== type
|| isThisTypeParameter(type)
|| type.flags & TypeFlags.Intersection && every((type as IntersectionType).types, t => t.symbol !== globalThisSymbol)) {
const propName = escapeLeadingUnderscores(literal.text);