diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1ac041a3653c2..280b3dc51ef1a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -25150,7 +25150,7 @@ namespace ts { function narrowByInKeyword(type: Type, name: __String, assumeTrue: boolean) { if (type.flags & TypeFlags.Union - || type.flags & TypeFlags.Object && declaredType !== type + || type.flags & TypeFlags.Object && declaredType !== type && !(declaredType === unknownType && isEmptyAnonymousObjectType(type)) || isThisTypeParameter(type) || type.flags & TypeFlags.Intersection && every((type as IntersectionType).types, t => t.symbol !== globalThisSymbol)) { return filterType(type, t => isTypePresencePossible(t, name, assumeTrue));