mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 21:06:50 -05:00
Redo in narrowing for intersections (#39637)
* Redo in-narrowing for intersections Still need to carve out an exception for globalThis * exempt globalThis from `in` narrowing
This commit is contained in:
committed by
GitHub
parent
32934a9989
commit
d3877d294c
@@ -21475,7 +21475,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
function narrowByInKeyword(type: Type, literal: LiteralExpression, assumeTrue: boolean) {
|
||||
if (type.flags & (TypeFlags.Union | TypeFlags.Object) || isThisTypeParameter(type)) {
|
||||
if (type.flags & (TypeFlags.Union | TypeFlags.Object)
|
||||
|| isThisTypeParameter(type)
|
||||
|| type.flags & TypeFlags.Intersection && every((type as IntersectionType).types, t => t.symbol !== globalThisSymbol)) {
|
||||
const propName = escapeLeadingUnderscores(literal.text);
|
||||
return filterType(type, t => isTypePresencePossible(t, propName, assumeTrue));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user