mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00: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:
1 parent
32934a9989
commit
d3877d294c
6 files changed
+72
-6
No files matched your search
@@ -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