mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 11:24:49 -05:00
in operator shouldn't narrow {} originating in unknown (#50610)
* 'in' operator shouldn't narrow {} originating in unknown
* Add regression test
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user